shopify-cli 2.7.0 → 2.7.1
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/.gitignore +1 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +27 -0
- data/ext/javy/javy.rb +186 -0
- data/ext/javy/version +1 -0
- data/lib/project_types/extension/commands/build.rb +1 -0
- data/lib/project_types/extension/tasks/convert_server_config.rb +1 -1
- data/lib/project_types/extension/tasks/run_extension_command.rb +1 -1
- data/lib/project_types/script/cli.rb +1 -0
- data/lib/project_types/script/commands/javy.rb +31 -0
- data/lib/project_types/script/config/extension_points.yml +2 -2
- data/lib/project_types/script/layers/infrastructure/errors.rb +8 -1
- data/lib/project_types/script/messages/messages.rb +13 -0
- data/lib/project_types/script/ui/error_handler.rb +1 -1
- data/lib/project_types/theme/messages/messages.rb +25 -1
- data/lib/shopify_cli/messages/messages.rb +1 -1
- data/lib/shopify_cli/services/app/create/node_service.rb +2 -0
- data/lib/shopify_cli/services/app/create/php_service.rb +1 -1
- data/lib/shopify_cli/services/app/create/rails_service.rb +2 -0
- data/lib/shopify_cli/theme/dev_server.rb +27 -16
- data/lib/shopify_cli/tunnel.rb +25 -20
- data/lib/shopify_cli/version.rb +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6009a6f735f27532db922768483b5563cc1a89417742616d0712837f7a4c3f8a
|
4
|
+
data.tar.gz: 501ee710f57e5ffc27f7f9abfbb23e155a55da8f67127bfe32031c46fa2df08e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 783329de6e2b6481c6ebcd747284dcd5e3c81c4303bf82f1d9a22e2e5f9a81aeda51a211c0344636ec03ff17fa1e5aae492fd750540387c85de4204bab8f4327
|
7
|
+
data.tar.gz: 6af49d1fff422d17362c2e05f68341fc530cd7849f7d375a39ea8cb5abcb5d825ed8a4f04d8f25cc9265c9b2660c57b028be280db23882d58506e7c184b0d4cc
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
From version 2.6.0, the sections in this file adhere to the [keep a changelog](https://keepachangelog.com/en/1.0.0/) specification.
|
2
2
|
## [Unreleased]
|
3
3
|
|
4
|
+
## Version 2.7.1
|
5
|
+
### Fixed
|
6
|
+
* [#1722](https://github.com/Shopify/shopify-cli/pull/1722): Fix `theme serve` failing when the port is already being used
|
7
|
+
* [#1751](https://github.com/Shopify/shopify-cli/pull/1751): A bug in the app creation flow that caused the CLI to abort when the form validation failed.
|
8
|
+
* [#1750](https://github.com/Shopify/shopify-cli/pull/1750): Runtime errors in Windows' environments when the `PATHEXT` environment variable is not defined.
|
9
|
+
* [#1758](https://github.com/Shopify/shopify-cli/pull/1758): Fix tunnel creation for expired anonymous tunnels
|
10
|
+
|
4
11
|
## Version 2.7.0
|
5
12
|
### Changed
|
6
13
|
* [#1650](https://github.com/Shopify/shopify-cli/pull/1650): **Breaking** Move app commands under `shopify app`.
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -146,6 +146,33 @@ namespace :extensions do
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
+
namespace :scripts do
|
150
|
+
namespace :javy do
|
151
|
+
task :symlink do
|
152
|
+
source = Paths.root("..", "javy", "target", "release", "javy")
|
153
|
+
error("Unable to find javy executable: #{executable}") unless File.executable?(source)
|
154
|
+
target = Paths.javy("javy")
|
155
|
+
File.delete(target) if File.exist?(target)
|
156
|
+
File.symlink(source, target)
|
157
|
+
end
|
158
|
+
|
159
|
+
task :install do
|
160
|
+
require_relative Paths.javy("javy.rb")
|
161
|
+
Javy.install
|
162
|
+
end
|
163
|
+
|
164
|
+
module Paths
|
165
|
+
def self.javy(*args)
|
166
|
+
root("ext", "javy", *args)
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.root(*args)
|
170
|
+
Pathname(File.dirname(__FILE__)).join(*args).to_s
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
149
176
|
def error(message, output: STDERR, code: 1)
|
150
177
|
output.puts(message)
|
151
178
|
exit(code)
|
data/ext/javy/javy.rb
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
require "rbconfig"
|
2
|
+
require "open-uri"
|
3
|
+
require "zlib"
|
4
|
+
require "open3"
|
5
|
+
|
6
|
+
module Javy
|
7
|
+
ROOT = __dir__
|
8
|
+
BIN_FOLDER = File.join(ROOT, "bin")
|
9
|
+
VERSION = File.read(File.join(ROOT, "version")).strip
|
10
|
+
TARGET = File.join(BIN_FOLDER, "javy-#{VERSION}")
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def install
|
14
|
+
ShopifyCLI::Result
|
15
|
+
.wrap { Installer.call(target: target, platform: platform, version: VERSION) }
|
16
|
+
.call
|
17
|
+
end
|
18
|
+
|
19
|
+
def build(source:, dest: nil)
|
20
|
+
ensure_installed
|
21
|
+
|
22
|
+
optional_args = []
|
23
|
+
optional_args += ["-o", dest] unless dest.nil?
|
24
|
+
|
25
|
+
ShopifyCLI::Result
|
26
|
+
.wrap { exec(source, *optional_args) }
|
27
|
+
.call
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def exec(*args, **kwargs)
|
33
|
+
out_and_err, stat = CLI::Kit::System.capture2e(target, *args, **kwargs)
|
34
|
+
raise ExecutionError, out_and_err unless stat.success?
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
def platform
|
39
|
+
Platform.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def target
|
43
|
+
platform.format_executable_path(TARGET)
|
44
|
+
end
|
45
|
+
|
46
|
+
def ensure_installed
|
47
|
+
delete_outdated_installations
|
48
|
+
install unless Installer.installed?(target: target)
|
49
|
+
end
|
50
|
+
|
51
|
+
def delete_outdated_installations
|
52
|
+
installed_binaries
|
53
|
+
.reject { |v| v == target }
|
54
|
+
.each { |file| File.delete(file) }
|
55
|
+
end
|
56
|
+
|
57
|
+
def installed_binaries
|
58
|
+
Dir[File.join(BIN_FOLDER, "javy-*")]
|
59
|
+
end
|
60
|
+
|
61
|
+
module Installer
|
62
|
+
def self.call(target:, platform:, version:)
|
63
|
+
asset = Asset.new(
|
64
|
+
platform: platform,
|
65
|
+
version: version,
|
66
|
+
owner: "Shopify",
|
67
|
+
repository: "javy",
|
68
|
+
basename: "javy"
|
69
|
+
)
|
70
|
+
|
71
|
+
downloaded = asset.download(target: target)
|
72
|
+
raise InstallationError.asset_not_found(platform: platform, version: version, url: asset.url) unless downloaded
|
73
|
+
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.installed?(target:)
|
78
|
+
File.executable?(target)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class Error < RuntimeError; end
|
84
|
+
class ExecutionError < Error; end
|
85
|
+
|
86
|
+
class InstallationError < Error
|
87
|
+
def self.cpu_unsupported
|
88
|
+
new("Javy is not supported on this CPU")
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.asset_not_found(platform:, version:, url:)
|
92
|
+
new(format(
|
93
|
+
"Unable to download javy %{version} for %{os} (%{cpu}) at %{url}",
|
94
|
+
version: version,
|
95
|
+
os: platform.os,
|
96
|
+
cpu: platform.cpu,
|
97
|
+
url: url
|
98
|
+
))
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
Asset = Struct.new(:platform, :version, :owner, :repository, :basename, keyword_init: true) do
|
103
|
+
def download(target:)
|
104
|
+
FileUtils.mkdir_p(BIN_FOLDER)
|
105
|
+
|
106
|
+
Dir.chdir(File.dirname(target)) do
|
107
|
+
File.open(File.basename(target), "wb") do |target_file|
|
108
|
+
decompress(url.open, target_file)
|
109
|
+
end
|
110
|
+
File.chmod(0755, target)
|
111
|
+
end
|
112
|
+
|
113
|
+
true
|
114
|
+
rescue OpenURI::HTTPError
|
115
|
+
false
|
116
|
+
end
|
117
|
+
|
118
|
+
def url
|
119
|
+
URI.parse(format(
|
120
|
+
"https://github.com/%{owner}/%{repository}/releases/download/%{version}/%{filename}",
|
121
|
+
owner: owner,
|
122
|
+
repository: repository,
|
123
|
+
version: version,
|
124
|
+
filename: filename
|
125
|
+
))
|
126
|
+
end
|
127
|
+
|
128
|
+
def filename
|
129
|
+
format(
|
130
|
+
"%{basename}-%{cpu}-%{os}-%{version}.gz",
|
131
|
+
basename: basename,
|
132
|
+
cpu: platform.cpu,
|
133
|
+
os: platform.os,
|
134
|
+
version: version
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
138
|
+
private
|
139
|
+
|
140
|
+
def decompress(source, target)
|
141
|
+
zlib = Zlib::GzipReader.new(source)
|
142
|
+
target << zlib.read
|
143
|
+
ensure
|
144
|
+
zlib.close
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
Platform = Struct.new(:ruby_config) do
|
149
|
+
def initialize(ruby_config = RbConfig::CONFIG)
|
150
|
+
super(ruby_config)
|
151
|
+
end
|
152
|
+
|
153
|
+
def to_s
|
154
|
+
format("%{cpu}-%{os}", cpu: cpu, os: os)
|
155
|
+
end
|
156
|
+
|
157
|
+
def os
|
158
|
+
case ruby_config.fetch("host_os")
|
159
|
+
when /linux/
|
160
|
+
"linux"
|
161
|
+
when /darwin/
|
162
|
+
"macos"
|
163
|
+
else
|
164
|
+
"windows"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def cpu
|
169
|
+
case ruby_config.fetch("host_cpu")
|
170
|
+
when "x64", "x86_64"
|
171
|
+
"x86_64"
|
172
|
+
else
|
173
|
+
raise InstallationError.cpu_unsupported
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def format_executable_path(path)
|
178
|
+
case os
|
179
|
+
when "windows"
|
180
|
+
File.extname(path) != ".exe" ? path + ".exe" : path
|
181
|
+
else
|
182
|
+
path
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
data/ext/javy/version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
v0.1.0
|
@@ -13,7 +13,7 @@ module Extension
|
|
13
13
|
property :resource_url, accepts: String
|
14
14
|
property! :store, accepts: String
|
15
15
|
property! :title, accepts: String
|
16
|
-
property
|
16
|
+
property :tunnel_url, accepts: String
|
17
17
|
property! :type, accepts: String
|
18
18
|
|
19
19
|
def self.call(*args)
|
@@ -15,7 +15,7 @@ module Extension
|
|
15
15
|
|
16
16
|
property! :command, accepts: SUPPORTED_COMMANDS
|
17
17
|
property! :type, accepts: Models::DevelopmentServerRequirements::SUPPORTED_EXTENSION_TYPES
|
18
|
-
property :context, accepts: ShopifyCLI::Context
|
18
|
+
property! :context, accepts: ShopifyCLI::Context
|
19
19
|
property :config_file_name, accepts: String
|
20
20
|
property :port, accepts: Integer, default: 39351
|
21
21
|
property :resource_url, accepts: String
|
@@ -13,6 +13,7 @@ module Script
|
|
13
13
|
hidden_feature(feature_set: :script_project)
|
14
14
|
subcommand :Create, "create", Project.project_filepath("commands/create")
|
15
15
|
subcommand :Push, "push", Project.project_filepath("commands/push")
|
16
|
+
subcommand :Javy, "javy", Project.project_filepath("commands/javy")
|
16
17
|
end
|
17
18
|
ShopifyCLI::Commands.register("Script::Command", "script")
|
18
19
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "shopify_cli"
|
3
|
+
require_relative "../../../../ext/javy/javy.rb"
|
4
|
+
|
5
|
+
module Script
|
6
|
+
class Command
|
7
|
+
class Javy < ShopifyCLI::Command::SubCommand
|
8
|
+
hidden_feature
|
9
|
+
|
10
|
+
prerequisite_task ensure_project_type: :script
|
11
|
+
|
12
|
+
options do |parser, flags|
|
13
|
+
parser.on("--in=IN") { |in_file| flags[:in_file] = in_file }
|
14
|
+
parser.on("--out=OUT") { |out_file| flags[:out_file] = out_file }
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(*)
|
18
|
+
source = options.flags[:in_file]
|
19
|
+
dest = options.flags[:out_file]
|
20
|
+
|
21
|
+
@ctx.abort(@ctx.message("script.javy.errors.invalid_arguments", ShopifyCLI::TOOL_NAME)) unless source
|
22
|
+
|
23
|
+
::Javy.build(source: source, dest: dest).unwrap { |e| @ctx.abort(e.message) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.help
|
27
|
+
ShopifyCLI::Context.message("script.javy.help", ShopifyCLI::TOOL_NAME)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -32,7 +32,7 @@ payment_methods:
|
|
32
32
|
package: "@shopify/scripts-checkout-apis"
|
33
33
|
typescript:
|
34
34
|
beta: true
|
35
|
-
package: "@shopify/scripts-checkout-apis
|
35
|
+
package: "@shopify/scripts-checkout-apis"
|
36
36
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
37
37
|
shipping_methods:
|
38
38
|
domain: 'checkout'
|
@@ -42,7 +42,7 @@ shipping_methods:
|
|
42
42
|
package: "@shopify/scripts-checkout-apis"
|
43
43
|
typescript:
|
44
44
|
beta: true
|
45
|
-
package: "@shopify/scripts-checkout-apis
|
45
|
+
package: "@shopify/scripts-checkout-apis"
|
46
46
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
47
47
|
discount_types:
|
48
48
|
beta: true
|
@@ -56,8 +56,15 @@ module Script
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
class DeprecatedEPError < ScriptProjectError
|
60
|
+
attr_reader(:extension_point)
|
61
|
+
def initialize(extension_point)
|
62
|
+
super()
|
63
|
+
@extension_point = extension_point
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
59
67
|
class DependencyInstallError < ScriptProjectError; end
|
60
|
-
class DeprecatedEPError < ScriptProjectError; end
|
61
68
|
class EmptyResponseError < ScriptProjectError; end
|
62
69
|
class InvalidResponseError < ScriptProjectError; end
|
63
70
|
class ForbiddenError < ScriptProjectError; end
|
@@ -176,6 +176,19 @@ module Script
|
|
176
176
|
script_pushed: "{{v}} Script pushed to app (API key: %{api_key}).",
|
177
177
|
},
|
178
178
|
|
179
|
+
javy: {
|
180
|
+
help: <<~HELP,
|
181
|
+
Compile the JavaScript code into WebAssembly.
|
182
|
+
Usage: {{command:%s script javy}}
|
183
|
+
Options:
|
184
|
+
{{command:--in}} The name of the JavaScript file that will be compiled.
|
185
|
+
{{command:--out}} The name of the file that the WebAssembly should be written to.
|
186
|
+
HELP
|
187
|
+
errors: {
|
188
|
+
invalid_arguments: "Javy was run with invalid arguments. Run {{command: %s script javy --help}} for more information.",
|
189
|
+
},
|
190
|
+
},
|
191
|
+
|
179
192
|
project_deps: {
|
180
193
|
none_required: "{{v}} None required",
|
181
194
|
checking_with_npm: "Checking dependencies with npm",
|
@@ -74,7 +74,7 @@ module Script
|
|
74
74
|
}
|
75
75
|
when Layers::Infrastructure::Errors::DeprecatedEPError
|
76
76
|
{
|
77
|
-
cause_of_error: ShopifyCLI::Context.message("script.error.deprecated_ep", e.
|
77
|
+
cause_of_error: ShopifyCLI::Context.message("script.error.deprecated_ep", e.extension_point),
|
78
78
|
help_suggestion: ShopifyCLI::Context.message("script.error.deprecated_ep_cause"),
|
79
79
|
}
|
80
80
|
when Layers::Domain::Errors::InvalidExtensionPointError
|
@@ -96,12 +96,36 @@ module Theme
|
|
96
96
|
{{command:--poll}} Force polling to detect file changes
|
97
97
|
{{command:--host=HOST}} Set which network interface the web server listens on. The default value is 127.0.0.1.
|
98
98
|
HELP
|
99
|
-
|
99
|
+
viewing_theme: "Viewing theme…",
|
100
|
+
syncing_theme: "Syncing theme #%s on %s",
|
100
101
|
open_fail: "Couldn't open the theme",
|
101
102
|
error: {
|
102
103
|
address_binding_error: "Couldn't bind to localhost."\
|
103
104
|
" To serve your theme, set a different address with {{command:%s theme serve --host=<address>}}",
|
104
105
|
},
|
106
|
+
serving: <<~SERVING,
|
107
|
+
|
108
|
+
Serving %s
|
109
|
+
|
110
|
+
SERVING
|
111
|
+
customize_or_preview: <<~CUSTOMIZE_OR_PREVIEW,
|
112
|
+
|
113
|
+
Customize this theme in the Online Store Editor:
|
114
|
+
{{green:%s}}
|
115
|
+
|
116
|
+
Share this theme preview:
|
117
|
+
{{green:%s}}
|
118
|
+
|
119
|
+
(Use Ctrl-C to stop)
|
120
|
+
CUSTOMIZE_OR_PREVIEW
|
121
|
+
ensure_user: <<~ENSURE_USER,
|
122
|
+
You are not authorized to edit themes on %s.
|
123
|
+
Make sure you are a user of that store, and allowed to edit themes.
|
124
|
+
ENSURE_USER
|
125
|
+
already_in_use_error: "Error",
|
126
|
+
address_already_in_use: "The address \"%s\" is already in use.",
|
127
|
+
try_this: "Try this",
|
128
|
+
try_port_option: "Use the --port=PORT option to serve the theme in a different port.",
|
105
129
|
},
|
106
130
|
check: {
|
107
131
|
help: <<~HELP,
|
@@ -764,7 +764,7 @@ module ShopifyCLI
|
|
764
764
|
Anonymized reports will be sent to Shopify.
|
765
765
|
MESSAGE
|
766
766
|
turned_off_message: <<~MESSAGE,
|
767
|
-
Turn on automatic reporting later
|
767
|
+
Turn on automatic reporting later with {{command:%s reporting on}}.
|
768
768
|
MESSAGE
|
769
769
|
},
|
770
770
|
whoami: {
|
@@ -39,6 +39,8 @@ module ShopifyCLI
|
|
39
39
|
form_options[:rails_opts] = rails_opts unless rails_opts.nil?
|
40
40
|
form = form_data(form_options)
|
41
41
|
|
42
|
+
raise ShopifyCLI::AbortSilent if form.nil?
|
43
|
+
|
42
44
|
ruby_version = Rails::Ruby.version(context)
|
43
45
|
context.abort(context.message("core.app.create.rails.error.invalid_ruby_version")) unless
|
44
46
|
ruby_version.satisfies?("~>2.5") || ruby_version.satisfies?("~>3.0.0")
|
@@ -36,6 +36,7 @@ module ShopifyCLI
|
|
36
36
|
@app = LocalAssets.new(ctx, @app, theme: theme)
|
37
37
|
@app = HotReload.new(ctx, @app, theme: theme, watcher: watcher, ignore_filter: ignore_filter)
|
38
38
|
stopped = false
|
39
|
+
address = "http://#{http_bind}:#{port}"
|
39
40
|
|
40
41
|
theme.ensure_exists!
|
41
42
|
|
@@ -44,8 +45,8 @@ module ShopifyCLI
|
|
44
45
|
stop
|
45
46
|
end
|
46
47
|
|
47
|
-
CLI::UI::Frame.open(@ctx.message("theme.serve.
|
48
|
-
ctx.print_task("
|
48
|
+
CLI::UI::Frame.open(@ctx.message("theme.serve.viewing_theme")) do
|
49
|
+
ctx.print_task(ctx.message("theme.serve.syncing_theme", theme.id, theme.shop))
|
49
50
|
@syncer.start_threads
|
50
51
|
if block_given?
|
51
52
|
yield @syncer
|
@@ -55,18 +56,9 @@ module ShopifyCLI
|
|
55
56
|
|
56
57
|
return if stopped
|
57
58
|
|
58
|
-
ctx.puts("")
|
59
|
-
ctx.
|
60
|
-
ctx.puts("")
|
61
|
-
ctx.open_url!("http://127.0.0.1:#{port}")
|
62
|
-
ctx.puts("")
|
63
|
-
ctx.puts("Customize this theme in the Online Store Editor:")
|
64
|
-
ctx.puts("{{green:#{theme.editor_url}}}")
|
65
|
-
ctx.puts("")
|
66
|
-
ctx.puts("Share this theme preview:")
|
67
|
-
ctx.puts("{{green:#{theme.preview_url}}}")
|
68
|
-
ctx.puts("")
|
69
|
-
ctx.puts("(Use Ctrl-C to stop)")
|
59
|
+
ctx.puts(ctx.message("theme.serve.serving", theme.root))
|
60
|
+
ctx.open_url!(address)
|
61
|
+
ctx.puts(ctx.message("theme.serve.customize_or_preview", theme.editor_url, theme.preview_url))
|
70
62
|
end
|
71
63
|
|
72
64
|
logger = if ctx.debug?
|
@@ -87,8 +79,9 @@ module ShopifyCLI
|
|
87
79
|
|
88
80
|
rescue ShopifyCLI::API::APIRequestForbiddenError,
|
89
81
|
ShopifyCLI::API::APIRequestUnauthorizedError
|
90
|
-
@ctx.
|
91
|
-
|
82
|
+
raise ShopifyCLI::Abort, @ctx.message("theme.serve.ensure_user", theme.shop)
|
83
|
+
rescue Errno::EADDRINUSE
|
84
|
+
abort_address_already_in_use(address)
|
92
85
|
rescue Errno::EADDRNOTAVAIL
|
93
86
|
raise AddressBindingError, "Error binding to the address #{http_bind}."
|
94
87
|
end
|
@@ -99,6 +92,24 @@ module ShopifyCLI
|
|
99
92
|
@syncer.shutdown
|
100
93
|
WebServer.shutdown
|
101
94
|
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def abort_address_already_in_use(address)
|
99
|
+
open_frame(@ctx.message("theme.serve.already_in_use_error"), color: :red) do
|
100
|
+
@ctx.puts(@ctx.message("theme.serve.address_already_in_use", address))
|
101
|
+
end
|
102
|
+
|
103
|
+
open_frame(@ctx.message("theme.serve.try_this"), color: :green) do
|
104
|
+
@ctx.puts(@ctx.message("theme.serve.try_port_option"))
|
105
|
+
end
|
106
|
+
|
107
|
+
raise ShopifyCLI::AbortSilent
|
108
|
+
end
|
109
|
+
|
110
|
+
def open_frame(title, color:, &block)
|
111
|
+
CLI::UI::Frame.open(title, color: CLI::UI.resolve_color(color), timing: false, &block)
|
112
|
+
end
|
102
113
|
end
|
103
114
|
end
|
104
115
|
end
|
data/lib/shopify_cli/tunnel.rb
CHANGED
@@ -12,7 +12,7 @@ module ShopifyCLI
|
|
12
12
|
class Tunnel
|
13
13
|
extend SingleForwardable
|
14
14
|
|
15
|
-
def_delegators :new, :start, :stop, :auth, :stats, :urls, :running_on?
|
15
|
+
def_delegators :new, :start, :stop, :auth, :authenticated?, :stats, :urls, :running_on?
|
16
16
|
|
17
17
|
class FetchUrlError < RuntimeError; end
|
18
18
|
class NgrokError < RuntimeError; end
|
@@ -65,16 +65,12 @@ module ShopifyCLI
|
|
65
65
|
#
|
66
66
|
def start(ctx, port: PORT)
|
67
67
|
install(ctx)
|
68
|
-
|
69
|
-
|
68
|
+
if authenticated?
|
69
|
+
url, account = start_ngrok(ctx, port)
|
70
70
|
ctx.puts(ctx.message("core.tunnel.start_with_account", url, account))
|
71
71
|
else
|
72
|
-
|
73
|
-
ctx.puts(ctx.message("core.tunnel.timed_out"))
|
74
|
-
url, _account, seconds_remaining = restart_ngrok(ctx, port)
|
75
|
-
end
|
72
|
+
url, _ = restart_ngrok(ctx, port)
|
76
73
|
ctx.puts(ctx.message("core.tunnel.start", url))
|
77
|
-
ctx.puts(ctx.message("core.tunnel.will_timeout", seconds_to_hm(seconds_remaining)))
|
78
74
|
ctx.puts(ctx.message("core.tunnel.signup_suggestion", ShopifyCLI::TOOL_NAME))
|
79
75
|
end
|
80
76
|
url
|
@@ -91,7 +87,16 @@ module ShopifyCLI
|
|
91
87
|
#
|
92
88
|
def auth(ctx, token)
|
93
89
|
install(ctx)
|
94
|
-
ctx.system(
|
90
|
+
ctx.system(ngrok_path, "authtoken", token)
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# returns a boolean: if the user has a ngrok token to authenticate
|
95
|
+
#
|
96
|
+
def authenticated?
|
97
|
+
ngrok_config_path = File.join(Dir.home, ".ngrok2/ngrok.yml")
|
98
|
+
return false unless File.exist?(ngrok_config_path)
|
99
|
+
File.read(ngrok_config_path).include?("authtoken")
|
95
100
|
end
|
96
101
|
|
97
102
|
##
|
@@ -145,7 +150,7 @@ module ShopifyCLI
|
|
145
150
|
|
146
151
|
def install(ctx)
|
147
152
|
ngrok = "ngrok#{ctx.executable_file_extension}"
|
148
|
-
return if File.exist?(
|
153
|
+
return if File.exist?(ngrok_path)
|
149
154
|
check_prereq_command(ctx, "curl")
|
150
155
|
check_prereq_command(ctx, ctx.linux? ? "unzip" : "tar")
|
151
156
|
spinner = CLI::UI::SpinGroup.new
|
@@ -165,7 +170,7 @@ module ShopifyCLI
|
|
165
170
|
spinner.wait
|
166
171
|
|
167
172
|
# final check to see if ngrok is accessible
|
168
|
-
unless File.exist?(
|
173
|
+
unless File.exist?(ngrok_path)
|
169
174
|
ctx.abort(ctx.message("core.tunnel.error.ngrok", ngrok, ShopifyCLI.cache_dir))
|
170
175
|
end
|
171
176
|
end
|
@@ -177,8 +182,12 @@ module ShopifyCLI
|
|
177
182
|
raise e.class, e.message
|
178
183
|
end
|
179
184
|
|
185
|
+
def ngrok_path
|
186
|
+
File.join(ShopifyCLI.cache_dir, "ngrok")
|
187
|
+
end
|
188
|
+
|
180
189
|
def ngrok_command(port)
|
181
|
-
"\"#{
|
190
|
+
"\"#{ngrok_path}\" http -inspect=false -log=stdout -log-level=debug #{port}"
|
182
191
|
end
|
183
192
|
|
184
193
|
def seconds_to_hm(seconds)
|
@@ -188,14 +197,11 @@ module ShopifyCLI
|
|
188
197
|
def start_ngrok(ctx, port)
|
189
198
|
process = ShopifyCLI::ProcessSupervision.start(:ngrok, ngrok_command(port))
|
190
199
|
log = fetch_url(ctx, process.log_path)
|
191
|
-
|
192
|
-
[log.url, log.account, seconds_remaining]
|
200
|
+
[log.url, log.account]
|
193
201
|
end
|
194
202
|
|
195
203
|
def restart_ngrok(ctx, port)
|
196
|
-
|
197
|
-
ctx.abort(ctx.message("core.tunnel.error.stop"))
|
198
|
-
end
|
204
|
+
ShopifyCLI::ProcessSupervision.stop(:ngrok)
|
199
205
|
start_ngrok(ctx, port)
|
200
206
|
end
|
201
207
|
|
@@ -208,7 +214,7 @@ module ShopifyCLI
|
|
208
214
|
class LogParser # :nodoc:
|
209
215
|
TIMEOUT = 10
|
210
216
|
|
211
|
-
attr_reader :url, :account
|
217
|
+
attr_reader :url, :account
|
212
218
|
|
213
219
|
def initialize(log_path)
|
214
220
|
@log_path = log_path
|
@@ -237,9 +243,8 @@ module ShopifyCLI
|
|
237
243
|
end
|
238
244
|
|
239
245
|
def parse_account
|
240
|
-
account,
|
246
|
+
account, _ = @log.match(/AccountName:(.*)\s+SessionDuration/)&.captures
|
241
247
|
@account = account&.empty? ? nil : account
|
242
|
-
@timeout = timeout&.empty? ? 0 : timeout.to_i
|
243
248
|
end
|
244
249
|
|
245
250
|
def error
|
data/lib/shopify_cli/version.rb
CHANGED
@@ -222,7 +222,7 @@ module CLI
|
|
222
222
|
end
|
223
223
|
|
224
224
|
def which(cmd, env)
|
225
|
-
exts = os == :windows ? env.fetch('PATHEXT').split(';') : ['']
|
225
|
+
exts = os == :windows ? env.fetch('PATHEXT', ['']).split(';') : ['']
|
226
226
|
env.fetch('PATH', '').split(File::PATH_SEPARATOR).each do |path|
|
227
227
|
exts.each do |ext|
|
228
228
|
exe = File.join(path, "#{cmd}#{ext}")
|
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.7.
|
4
|
+
version: 2.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -150,6 +150,8 @@ files:
|
|
150
150
|
- docs/contributors/testing.md
|
151
151
|
- docs/users/installation.md
|
152
152
|
- docs/users/migrate-from-themekit.md
|
153
|
+
- ext/javy/javy.rb
|
154
|
+
- ext/javy/version
|
153
155
|
- ext/shopify-extensions/extconf.rb
|
154
156
|
- ext/shopify-extensions/shopify_extensions.rb
|
155
157
|
- ext/shopify-extensions/version
|
@@ -269,6 +271,7 @@ files:
|
|
269
271
|
- lib/project_types/rails/ruby.rb
|
270
272
|
- lib/project_types/script/cli.rb
|
271
273
|
- lib/project_types/script/commands/create.rb
|
274
|
+
- lib/project_types/script/commands/javy.rb
|
272
275
|
- lib/project_types/script/commands/push.rb
|
273
276
|
- lib/project_types/script/config/extension_points.yml
|
274
277
|
- lib/project_types/script/errors.rb
|