shopify-cli 2.6.5 → 2.7.2
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/.devcontainer.json +5 -0
- data/.github/DESIGN.md +1 -1
- data/.github/ISSUE_TEMPLATE.md +7 -0
- data/.gitignore +1 -0
- data/.vscode/extensions.json +5 -0
- data/.vscode/settings.json +9 -0
- data/CHANGELOG.md +42 -4
- data/CONTRIBUTING.md +1 -21
- data/{Dockerfile → Codespace.dockerfile} +11 -3
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -4
- data/README.md +20 -99
- data/Rakefile +27 -0
- data/Tests.dockerfile +35 -0
- data/assets/logo.png +0 -0
- data/dev.yml +0 -3
- data/docs/README.md +13 -0
- data/docs/contributors/testing.md +27 -0
- data/docs/users/installation.md +46 -0
- data/{THEMEKIT_MIGRATION.md → docs/users/migrate-from-themekit.md} +1 -1
- data/ext/javy/javy.rb +186 -0
- data/ext/javy/version +1 -0
- data/lib/project_types/extension/cli.rb +7 -3
- data/lib/project_types/extension/commands/build.rb +4 -8
- data/lib/project_types/extension/commands/create.rb +3 -5
- data/lib/project_types/extension/commands/extension_command.rb +1 -1
- data/lib/project_types/extension/features/argo.rb +1 -8
- data/lib/project_types/extension/features/argo_serve.rb +9 -23
- data/lib/project_types/extension/forms/create.rb +1 -1
- data/lib/project_types/extension/forms/questions/ask_template.rb +3 -6
- data/lib/project_types/extension/messages/messages.rb +1 -2
- data/lib/project_types/extension/models/development_server.rb +2 -2
- data/lib/project_types/extension/models/development_server_requirements.rb +2 -3
- data/lib/project_types/extension/models/server_config/app.rb +13 -0
- data/lib/project_types/extension/models/server_config/development.rb +5 -4
- data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
- data/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
- data/lib/project_types/extension/models/server_config/extension.rb +4 -0
- data/lib/project_types/extension/models/server_config/root.rb +4 -1
- data/lib/project_types/extension/tasks/convert_server_config.rb +65 -0
- data/lib/project_types/extension/tasks/ensure_resource_url.rb +39 -0
- data/lib/project_types/extension/tasks/find_package_from_json.rb +37 -0
- data/lib/project_types/extension/tasks/merge_server_config.rb +32 -0
- data/lib/project_types/extension/tasks/run_extension_command.rb +11 -10
- data/lib/project_types/node/cli.rb +0 -16
- data/lib/project_types/node/forms/create.rb +5 -5
- data/lib/project_types/node/messages/messages.rb +2 -144
- data/lib/project_types/php/cli.rb +0 -11
- data/lib/project_types/php/forms/create.rb +5 -6
- data/lib/project_types/php/messages/messages.rb +2 -161
- data/lib/project_types/rails/cli.rb +0 -16
- data/lib/project_types/rails/commands/create.rb +43 -16
- data/lib/project_types/rails/forms/create.rb +5 -7
- data/lib/project_types/rails/messages/messages.rb +6 -151
- data/lib/project_types/script/cli.rb +7 -1
- data/lib/project_types/script/commands/create.rb +3 -8
- data/lib/project_types/script/commands/javy.rb +29 -0
- data/lib/project_types/script/commands/push.rb +3 -2
- data/lib/project_types/script/config/extension_points.yml +3 -26
- data/lib/project_types/script/errors.rb +0 -18
- data/lib/project_types/script/forms/ask_app.rb +32 -0
- data/lib/project_types/script/forms/ask_org.rb +30 -0
- data/lib/project_types/script/forms/ask_script_uuid.rb +22 -0
- data/lib/project_types/script/forms/run_against_shopify_org.rb +14 -0
- data/lib/project_types/script/layers/application/build_script.rb +0 -1
- data/lib/project_types/script/layers/application/connect_app.rb +73 -0
- data/lib/project_types/script/layers/application/create_script.rb +2 -2
- data/lib/project_types/script/layers/domain/script_json.rb +1 -1
- data/lib/project_types/script/layers/domain/script_project.rb +4 -0
- data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -4
- data/lib/project_types/script/layers/infrastructure/errors.rb +8 -4
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +1 -5
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +25 -4
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +3 -4
- data/lib/project_types/script/layers/infrastructure/script_service.rb +1 -1
- data/lib/project_types/script/messages/messages.rb +16 -20
- data/lib/project_types/script/ui/error_handler.rb +1 -32
- data/lib/project_types/theme/cli.rb +1 -1
- data/lib/project_types/theme/commands/check.rb +1 -1
- data/lib/project_types/theme/commands/delete.rb +1 -1
- data/lib/project_types/theme/commands/init.rb +1 -1
- data/lib/project_types/theme/commands/language_server.rb +1 -1
- data/lib/project_types/theme/commands/package.rb +1 -1
- data/lib/project_types/theme/commands/publish.rb +1 -1
- data/lib/project_types/theme/commands/pull.rb +4 -1
- data/lib/project_types/theme/commands/push.rb +7 -2
- data/lib/project_types/theme/commands/serve.rb +9 -2
- data/lib/project_types/theme/messages/messages.rb +39 -1
- data/lib/project_types/theme/ui/sync_progress_bar.rb +2 -2
- data/lib/shopify_cli/admin_api/populate_resource_command.rb +1 -1
- data/lib/shopify_cli/api.rb +7 -2
- data/lib/shopify_cli/app_type_detector.rb +24 -20
- data/lib/shopify_cli/command/app_sub_command.rb +10 -0
- data/lib/shopify_cli/command/project_command.rb +31 -0
- data/lib/shopify_cli/command/sub_command.rb +19 -0
- data/lib/shopify_cli/command.rb +7 -2
- data/lib/shopify_cli/commands/app/connect.rb +22 -0
- data/lib/shopify_cli/commands/app/create/node.rb +36 -0
- data/lib/shopify_cli/commands/app/create/php.rb +36 -0
- data/lib/shopify_cli/commands/app/create/rails.rb +38 -0
- data/lib/shopify_cli/commands/app/create.rb +28 -0
- data/lib/shopify_cli/commands/app/deploy.rb +49 -0
- data/lib/shopify_cli/commands/app/open.rb +19 -0
- data/lib/shopify_cli/commands/app/serve.rb +49 -0
- data/lib/shopify_cli/commands/app/tunnel.rb +43 -0
- data/lib/shopify_cli/commands/app.rb +29 -0
- data/lib/shopify_cli/commands/config.rb +2 -2
- data/lib/shopify_cli/commands.rb +1 -0
- data/lib/shopify_cli/constants.rb +7 -0
- data/lib/shopify_cli/context.rb +9 -0
- data/lib/shopify_cli/environment.rb +4 -0
- data/lib/shopify_cli/exception_reporter.rb +8 -6
- data/lib/shopify_cli/git.rb +12 -1
- data/lib/shopify_cli/github/issue_url_generator.rb +19 -0
- data/lib/shopify_cli/github.rb +5 -0
- data/lib/shopify_cli/identity_auth.rb +18 -0
- data/lib/shopify_cli/messages/messages.rb +254 -9
- data/lib/shopify_cli/migrator.rb +9 -11
- data/lib/shopify_cli/partners_api.rb +1 -8
- data/lib/shopify_cli/project.rb +5 -1
- data/lib/shopify_cli/project_commands.rb +1 -1
- data/lib/shopify_cli/services/app/connect_service.rb +25 -0
- data/lib/shopify_cli/services/app/create/node_service.rb +155 -0
- data/lib/shopify_cli/services/app/create/php_service.rb +152 -0
- data/lib/shopify_cli/services/app/create/rails_service.rb +215 -0
- data/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
- data/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
- data/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
- data/lib/shopify_cli/services/app/open_service.rb +19 -0
- data/lib/shopify_cli/services/app/serve/node_service.rb +42 -0
- data/lib/shopify_cli/services/app/serve/php_service.rb +46 -0
- data/lib/shopify_cli/services/app/serve/rails_service.rb +48 -0
- data/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
- data/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
- data/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
- data/lib/shopify_cli/services.rb +31 -0
- data/lib/shopify_cli/tasks/ensure_authenticated.rb +9 -3
- data/lib/shopify_cli/theme/dev_server/local_assets.rb +1 -1
- data/lib/shopify_cli/theme/dev_server.rb +35 -17
- data/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
- data/lib/shopify_cli/theme/syncer/operation.rb +56 -0
- data/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
- data/lib/shopify_cli/theme/syncer.rb +40 -39
- data/lib/shopify_cli/theme/theme.rb +31 -19
- data/lib/shopify_cli/tunnel.rb +25 -22
- data/lib/shopify_cli/version.rb +1 -1
- data/lib/shopify_cli.rb +1 -2
- data/shopify-cli.gemspec +2 -6
- data/shopify-dev +18 -0
- data/utilities/constants.rb +7 -0
- data/utilities/docker/container.rb +30 -2
- data/utilities/docker.rb +3 -2
- data/utilities/utilities.rb +1 -0
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
- metadata +64 -54
- data/docs/_config.yml +0 -2
- data/docs/app/node/commands/index.md +0 -4
- data/docs/app/node/index.md +0 -4
- data/docs/app/rails/commands/index.md +0 -4
- data/docs/app/rails/index.md +0 -4
- data/docs/core/index.md +0 -4
- data/docs/getting-started/index.md +0 -4
- data/docs/getting-started/install/index.md +0 -4
- data/docs/getting-started/migrate/index.md +0 -4
- data/docs/getting-started/uninstall/index.md +0 -4
- data/docs/getting-started/upgrade/index.md +0 -4
- data/docs/help/start-app/index.md +0 -4
- data/docs/index.md +0 -4
- data/ext/shopify-cli/extconf.rb +0 -60
- data/install.sh +0 -7
- data/lib/project_types/extension/tasks/converters/server_config_converter.rb +0 -31
- data/lib/project_types/extension/tasks/load_server_config.rb +0 -23
- data/lib/project_types/node/commands/connect.rb +0 -21
- data/lib/project_types/node/commands/create.rb +0 -125
- data/lib/project_types/node/commands/deploy/heroku.rb +0 -96
- data/lib/project_types/node/commands/deploy.rb +0 -32
- data/lib/project_types/node/commands/generate.rb +0 -22
- data/lib/project_types/node/commands/open.rb +0 -18
- data/lib/project_types/node/commands/serve.rb +0 -45
- data/lib/project_types/node/commands/tunnel.rb +0 -41
- data/lib/project_types/php/commands/connect.rb +0 -19
- data/lib/project_types/php/commands/create.rb +0 -143
- data/lib/project_types/php/commands/deploy/heroku.rb +0 -129
- data/lib/project_types/php/commands/deploy.rb +0 -32
- data/lib/project_types/php/commands/open.rb +0 -16
- data/lib/project_types/php/commands/serve.rb +0 -48
- data/lib/project_types/php/commands/tunnel.rb +0 -37
- data/lib/project_types/rails/commands/connect.rb +0 -21
- data/lib/project_types/rails/commands/deploy/heroku.rb +0 -115
- data/lib/project_types/rails/commands/deploy.rb +0 -32
- data/lib/project_types/rails/commands/generate/webhook.rb +0 -42
- data/lib/project_types/rails/commands/generate.rb +0 -60
- data/lib/project_types/rails/commands/open.rb +0 -18
- data/lib/project_types/rails/commands/serve.rb +0 -51
- data/lib/project_types/rails/commands/tunnel.rb +0 -41
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -0
- data/lib/project_types/script/tasks/ensure_env.rb +0 -106
- data/lib/shopify_cli/sub_command.rb +0 -17
- data/shopify.fish +0 -12
- data/shopify.sh +0 -11
|
@@ -2,24 +2,31 @@
|
|
|
2
2
|
require "thread"
|
|
3
3
|
require "json"
|
|
4
4
|
require "base64"
|
|
5
|
+
require "forwardable"
|
|
6
|
+
|
|
7
|
+
require_relative "syncer/error_reporter"
|
|
8
|
+
require_relative "syncer/standard_reporter"
|
|
9
|
+
require_relative "syncer/operation"
|
|
5
10
|
|
|
6
11
|
module ShopifyCLI
|
|
7
12
|
module Theme
|
|
8
13
|
class Syncer
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"#{method} #{file&.relative_path}"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
+
extend Forwardable
|
|
15
|
+
|
|
14
16
|
API_VERSION = "unstable"
|
|
15
17
|
|
|
16
18
|
attr_reader :checksums
|
|
17
19
|
attr_accessor :ignore_filter
|
|
18
20
|
|
|
21
|
+
def_delegators :@error_reporter, :has_any_error?
|
|
22
|
+
|
|
19
23
|
def initialize(ctx, theme:, ignore_filter: nil)
|
|
20
24
|
@ctx = ctx
|
|
21
25
|
@theme = theme
|
|
22
26
|
@ignore_filter = ignore_filter
|
|
27
|
+
@error_reporter = ErrorReporter.new(ctx)
|
|
28
|
+
@standard_reporter = StandardReporter.new(ctx)
|
|
29
|
+
@reporters = [@error_reporter, @standard_reporter]
|
|
23
30
|
|
|
24
31
|
# Queue of `Operation`s waiting to be picked up from a thread for processing.
|
|
25
32
|
@queue = Queue.new
|
|
@@ -30,12 +37,19 @@ module ShopifyCLI
|
|
|
30
37
|
# Mutex used to pause all threads when backing-off when hitting API rate limits
|
|
31
38
|
@backoff_mutex = Mutex.new
|
|
32
39
|
|
|
33
|
-
# Allows delaying log of errors, mainly to not break the progress bar.
|
|
34
|
-
@delay_errors = false
|
|
35
|
-
@delayed_errors = []
|
|
36
|
-
|
|
37
40
|
# Latest theme assets checksums. Updated on each upload.
|
|
38
41
|
@checksums = {}
|
|
42
|
+
|
|
43
|
+
# Checksums of assets with errors.
|
|
44
|
+
@error_checksums = []
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def lock_io!
|
|
48
|
+
@reporters.each { |reporter| reporter.disable! }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def unlock_io!
|
|
52
|
+
@reporters.each { |reporter| reporter.enable! }
|
|
39
53
|
end
|
|
40
54
|
|
|
41
55
|
def enqueue_updates(files)
|
|
@@ -103,25 +117,14 @@ module ShopifyCLI
|
|
|
103
117
|
break if operation.nil? # shutdown was called
|
|
104
118
|
perform(operation)
|
|
105
119
|
rescue Exception => e
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
)
|
|
120
|
+
error_suffix = ": #{e}"
|
|
121
|
+
error_suffix += + "\n\t#{e.backtrace.join("\n\t")}" if @ctx.debug?
|
|
122
|
+
report_error(operation, error_suffix)
|
|
110
123
|
end
|
|
111
124
|
end
|
|
112
125
|
end
|
|
113
126
|
end
|
|
114
127
|
|
|
115
|
-
def delay_errors!
|
|
116
|
-
@delay_errors = true
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def report_errors!
|
|
120
|
-
@delay_errors = false
|
|
121
|
-
@delayed_errors.each { |error| report_error(error) }
|
|
122
|
-
@delayed_errors.clear
|
|
123
|
-
end
|
|
124
|
-
|
|
125
128
|
def upload_theme!(delay_low_priority_files: false, delete: true, &block)
|
|
126
129
|
fetch_checksums!
|
|
127
130
|
|
|
@@ -177,21 +180,27 @@ module ShopifyCLI
|
|
|
177
180
|
|
|
178
181
|
private
|
|
179
182
|
|
|
183
|
+
def report_error(operation, error_suffix = "")
|
|
184
|
+
@error_checksums << @checksums[operation.file_path]
|
|
185
|
+
@error_reporter.report("#{operation.as_error_message}#{error_suffix}")
|
|
186
|
+
end
|
|
187
|
+
|
|
180
188
|
def enqueue(method, file)
|
|
181
189
|
raise ArgumentError, "file required" unless file
|
|
182
190
|
|
|
183
|
-
operation = Operation.new(method, @theme[file])
|
|
191
|
+
operation = Operation.new(@ctx, method, @theme[file])
|
|
184
192
|
|
|
185
193
|
# Already enqueued
|
|
186
194
|
return if @pending.include?(operation)
|
|
187
195
|
|
|
188
|
-
if @ignore_filter&.ignore?(operation.
|
|
189
|
-
@ctx.debug("ignore #{operation.
|
|
196
|
+
if @ignore_filter&.ignore?(operation.file_path)
|
|
197
|
+
@ctx.debug("ignore #{operation.file_path}")
|
|
190
198
|
return
|
|
191
199
|
end
|
|
192
200
|
|
|
193
201
|
if [:update, :get].include?(method) && operation.file.exist? && !file_has_changed?(operation.file)
|
|
194
|
-
|
|
202
|
+
is_fixed = !!@error_checksums.delete(operation.file.checksum)
|
|
203
|
+
@standard_reporter.report(operation.as_fix_message) if is_fixed
|
|
195
204
|
return
|
|
196
205
|
end
|
|
197
206
|
|
|
@@ -206,16 +215,16 @@ module ShopifyCLI
|
|
|
206
215
|
|
|
207
216
|
response = send(operation.method, operation.file)
|
|
208
217
|
|
|
218
|
+
@standard_reporter.report(operation.as_synced_message)
|
|
219
|
+
|
|
209
220
|
# Check if the API told us we're near the rate limit
|
|
210
221
|
if !backingoff? && (limit = response["x-shopify-shop-api-call-limit"])
|
|
211
222
|
used, total = limit.split("/").map(&:to_i)
|
|
212
223
|
backoff_if_near_limit!(used, total)
|
|
213
224
|
end
|
|
214
225
|
rescue ShopifyCLI::API::APIRequestError => e
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
parse_api_errors(e).join("\n ")
|
|
218
|
-
)
|
|
226
|
+
error_suffix = ":\n " + parse_api_errors(e).join("\n ")
|
|
227
|
+
report_error(operation, error_suffix)
|
|
219
228
|
ensure
|
|
220
229
|
@pending.delete(operation)
|
|
221
230
|
end
|
|
@@ -295,14 +304,6 @@ module ShopifyCLI
|
|
|
295
304
|
file.checksum != @checksums[file.relative_path.to_s]
|
|
296
305
|
end
|
|
297
306
|
|
|
298
|
-
def report_error(error)
|
|
299
|
-
if @delay_errors
|
|
300
|
-
@delayed_errors << error
|
|
301
|
-
else
|
|
302
|
-
@ctx.puts(error)
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
|
|
306
307
|
def parse_api_errors(exception)
|
|
307
308
|
parsed_body = JSON.parse(exception&.response&.body)
|
|
308
309
|
message = parsed_body.dig("errors", "asset") || parsed_body["message"] || exception.message
|
|
@@ -162,26 +162,38 @@ module ShopifyCLI
|
|
|
162
162
|
}
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
ctx
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
class << self
|
|
166
|
+
def all(ctx, root: nil)
|
|
167
|
+
_status, body = fetch_themes(ctx)
|
|
168
|
+
|
|
169
|
+
body["themes"]
|
|
170
|
+
.sort_by { |theme_attrs| Time.parse(theme_attrs["updated_at"]) }
|
|
171
|
+
.reverse
|
|
172
|
+
.map { |theme_attrs| new(ctx, root: root, **allowed_attrs(theme_attrs)) }
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def live(ctx, root: nil)
|
|
176
|
+
_status, body = fetch_themes(ctx)
|
|
172
177
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
body["themes"]
|
|
179
|
+
.find { |theme_attrs| theme_attrs["role"] == "main" }
|
|
180
|
+
.tap { |theme_attrs| break new(ctx, root: root, **allowed_attrs(theme_attrs)) }
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
private
|
|
184
|
+
|
|
185
|
+
def allowed_attrs(attrs)
|
|
186
|
+
attrs.slice("id", "name", "role").transform_keys(&:to_sym)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def fetch_themes(ctx)
|
|
190
|
+
AdminAPI.rest_request(
|
|
191
|
+
ctx,
|
|
192
|
+
shop: AdminAPI.get_shop_or_abort(ctx),
|
|
193
|
+
path: "themes.json",
|
|
194
|
+
api_version: "unstable",
|
|
195
|
+
)
|
|
196
|
+
end
|
|
185
197
|
end
|
|
186
198
|
|
|
187
199
|
private
|
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(ctx), "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(ctx))
|
|
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(ctx))
|
|
169
174
|
ctx.abort(ctx.message("core.tunnel.error.ngrok", ngrok, ShopifyCLI.cache_dir))
|
|
170
175
|
end
|
|
171
176
|
end
|
|
@@ -177,8 +182,9 @@ module ShopifyCLI
|
|
|
177
182
|
raise e.class, e.message
|
|
178
183
|
end
|
|
179
184
|
|
|
180
|
-
def
|
|
181
|
-
|
|
185
|
+
def ngrok_path(ctx)
|
|
186
|
+
ngrok = "ngrok#{ctx.executable_file_extension}"
|
|
187
|
+
File.join(ShopifyCLI.cache_dir, ngrok)
|
|
182
188
|
end
|
|
183
189
|
|
|
184
190
|
def seconds_to_hm(seconds)
|
|
@@ -186,16 +192,14 @@ module ShopifyCLI
|
|
|
186
192
|
end
|
|
187
193
|
|
|
188
194
|
def start_ngrok(ctx, port)
|
|
189
|
-
|
|
195
|
+
ngrok_command = "\"#{ngrok_path(ctx)}\" http -inspect=false -log=stdout -log-level=debug #{port}"
|
|
196
|
+
process = ShopifyCLI::ProcessSupervision.start(:ngrok, ngrok_command)
|
|
190
197
|
log = fetch_url(ctx, process.log_path)
|
|
191
|
-
|
|
192
|
-
[log.url, log.account, seconds_remaining]
|
|
198
|
+
[log.url, log.account]
|
|
193
199
|
end
|
|
194
200
|
|
|
195
201
|
def restart_ngrok(ctx, port)
|
|
196
|
-
|
|
197
|
-
ctx.abort(ctx.message("core.tunnel.error.stop"))
|
|
198
|
-
end
|
|
202
|
+
ShopifyCLI::ProcessSupervision.stop(:ngrok)
|
|
199
203
|
start_ngrok(ctx, port)
|
|
200
204
|
end
|
|
201
205
|
|
|
@@ -208,7 +212,7 @@ module ShopifyCLI
|
|
|
208
212
|
class LogParser # :nodoc:
|
|
209
213
|
TIMEOUT = 10
|
|
210
214
|
|
|
211
|
-
attr_reader :url, :account
|
|
215
|
+
attr_reader :url, :account
|
|
212
216
|
|
|
213
217
|
def initialize(log_path)
|
|
214
218
|
@log_path = log_path
|
|
@@ -237,9 +241,8 @@ module ShopifyCLI
|
|
|
237
241
|
end
|
|
238
242
|
|
|
239
243
|
def parse_account
|
|
240
|
-
account,
|
|
244
|
+
account, _ = @log.match(/AccountName:(.*)\s+SessionDuration/)&.captures
|
|
241
245
|
@account = account&.empty? ? nil : account
|
|
242
|
-
@timeout = timeout&.empty? ? 0 : timeout.to_i
|
|
243
246
|
end
|
|
244
247
|
|
|
245
248
|
def error
|
data/lib/shopify_cli/version.rb
CHANGED
data/lib/shopify_cli.rb
CHANGED
|
@@ -111,6 +111,7 @@ module ShopifyCLI
|
|
|
111
111
|
autoload :Feature, "shopify_cli/feature"
|
|
112
112
|
autoload :Form, "shopify_cli/form"
|
|
113
113
|
autoload :Git, "shopify_cli/git"
|
|
114
|
+
autoload :GitHub, "shopify_cli/github"
|
|
114
115
|
autoload :Helpers, "shopify_cli/helpers"
|
|
115
116
|
autoload :Heroku, "shopify_cli/heroku"
|
|
116
117
|
autoload :IdentityAuth, "shopify_cli/identity_auth"
|
|
@@ -123,7 +124,6 @@ module ShopifyCLI
|
|
|
123
124
|
autoload :PartnersAPI, "shopify_cli/partners_api"
|
|
124
125
|
autoload :ProcessSupervision, "shopify_cli/process_supervision"
|
|
125
126
|
autoload :Project, "shopify_cli/project"
|
|
126
|
-
autoload :ProjectCommands, "shopify_cli/project_commands"
|
|
127
127
|
autoload :ProjectType, "shopify_cli/project_type"
|
|
128
128
|
autoload :ReportingConfigurationController, "shopify_cli/reporting_configuration_controller"
|
|
129
129
|
autoload :ResolveConstant, "shopify_cli/resolve_constant"
|
|
@@ -131,7 +131,6 @@ module ShopifyCLI
|
|
|
131
131
|
autoload :Result, "shopify_cli/result"
|
|
132
132
|
autoload :Services, "shopify_cli/services"
|
|
133
133
|
autoload :Shopifolk, "shopify_cli/shopifolk"
|
|
134
|
-
autoload :SubCommand, "shopify_cli/sub_command"
|
|
135
134
|
autoload :Task, "shopify_cli/task"
|
|
136
135
|
autoload :Tasks, "shopify_cli/tasks"
|
|
137
136
|
autoload :TransformDataStructure, "shopify_cli/transform_data_structure"
|
data/shopify-cli.gemspec
CHANGED
|
@@ -33,11 +33,7 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
end
|
|
34
34
|
spec.bindir = "bin"
|
|
35
35
|
spec.require_paths = ["lib", "vendor"]
|
|
36
|
-
spec.
|
|
37
|
-
# Do NOT include `shopify` as a listed executable via `spec.executables`.
|
|
38
|
-
# `ext/shopify-cli/extconf.rb` will dynamically create a script and soft-link
|
|
39
|
-
# `/usr/local/bin/shopify` to that script, in order to "lock" the Ruby used to
|
|
40
|
-
# a single Ruby (useful for debugging in multi-Ruby environments)
|
|
36
|
+
spec.executables << "shopify"
|
|
41
37
|
|
|
42
38
|
spec.add_development_dependency("bundler", "~> 2.2.2")
|
|
43
39
|
spec.add_development_dependency("rake", "~> 12.3", ">= 12.3.3")
|
|
@@ -45,5 +41,5 @@ Gem::Specification.new do |spec|
|
|
|
45
41
|
|
|
46
42
|
spec.add_dependency("bugsnag", "~> 6.22")
|
|
47
43
|
spec.add_dependency("listen", "~> 3.7.0")
|
|
48
|
-
spec.add_dependency("theme-check", "~> 1.
|
|
44
|
+
spec.add_dependency("theme-check", "~> 1.8.0")
|
|
49
45
|
end
|
data/shopify-dev
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require_relative "./bin/load_shopify"
|
|
4
|
+
|
|
5
|
+
exit(proc do
|
|
6
|
+
begin
|
|
7
|
+
ShopifyCLI::ErrorHandler.call do
|
|
8
|
+
ShopifyCLI::Core::EntryPoint.call(ARGV.dup)
|
|
9
|
+
end
|
|
10
|
+
rescue StandardError => error
|
|
11
|
+
ShopifyCLI::ErrorHandler.exception = error
|
|
12
|
+
if ShopifyCLI::Environment.print_stacktrace?
|
|
13
|
+
raise error
|
|
14
|
+
else
|
|
15
|
+
1
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end.call)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
require "open3"
|
|
2
|
+
require "colorize"
|
|
2
3
|
|
|
3
4
|
module Utilities
|
|
4
5
|
module Docker
|
|
5
6
|
class Container
|
|
7
|
+
SHOPIFY_PATH = "/usr/src/app"
|
|
6
8
|
SHOPIFY_BIN_PATH = "/usr/src/app/bin/shopify"
|
|
7
9
|
|
|
8
10
|
Error = Class.new(StandardError)
|
|
@@ -55,6 +57,10 @@ module Utilities
|
|
|
55
57
|
end
|
|
56
58
|
|
|
57
59
|
def exec(*args, relative_dir: nil)
|
|
60
|
+
if ARGV.include?("--verbose")
|
|
61
|
+
running_prefix = "Running command: #{args.join(" ")}"
|
|
62
|
+
STDOUT.puts(running_prefix.colorize(:yellow).bold)
|
|
63
|
+
end
|
|
58
64
|
command = ["docker", "exec"]
|
|
59
65
|
cwd = if relative_dir.nil?
|
|
60
66
|
@cwd
|
|
@@ -68,8 +74,30 @@ module Utilities
|
|
|
68
74
|
command << @id
|
|
69
75
|
command += args
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
docker_prefix = "Docker (#{args.first}):"
|
|
78
|
+
|
|
79
|
+
if ARGV.include?("--verbose")
|
|
80
|
+
stat = Open3.popen3(*command) do |stdin, stdout, stderr, wait_thread|
|
|
81
|
+
Thread.new do
|
|
82
|
+
stdout.each { |l| STDOUT.puts("#{docker_prefix.colorize(:cyan).bold} #{l}") } unless stdout&.nil?
|
|
83
|
+
end
|
|
84
|
+
Thread.new do
|
|
85
|
+
stderr.each { |l| STDERR.puts("#{docker_prefix.colorize(:red).bold} #{l}") } unless stderr&.nil?
|
|
86
|
+
end
|
|
87
|
+
stdin.close
|
|
88
|
+
|
|
89
|
+
status = wait_thread.value
|
|
90
|
+
|
|
91
|
+
stdout.close
|
|
92
|
+
stderr.close
|
|
93
|
+
|
|
94
|
+
status
|
|
95
|
+
end
|
|
96
|
+
raise StandardError, "The command #{args.first} failed" unless stat.success?
|
|
97
|
+
else
|
|
98
|
+
out, stat = Open3.capture2e(*command)
|
|
99
|
+
raise Error, out unless stat.success?
|
|
100
|
+
end
|
|
73
101
|
end
|
|
74
102
|
end
|
|
75
103
|
end
|
data/utilities/docker.rb
CHANGED
|
@@ -57,8 +57,9 @@ module Utilities
|
|
|
57
57
|
|
|
58
58
|
def build_image_if_needed
|
|
59
59
|
unless image_exists?(image_tag)
|
|
60
|
+
puts "Rebuilding the Docker image..."
|
|
60
61
|
_, err, stat = Open3.capture3(
|
|
61
|
-
"docker", "build",
|
|
62
|
+
"docker", "build", "-t", image_tag, "-f", File.join(root_dir, "Tests.dockerfile"), root_dir
|
|
62
63
|
)
|
|
63
64
|
raise Error, err unless stat.success?
|
|
64
65
|
end
|
|
@@ -66,7 +67,7 @@ module Utilities
|
|
|
66
67
|
|
|
67
68
|
def image_tag
|
|
68
69
|
gemfile_lock_path = File.expand_path("./Gemfile.lock", root_dir)
|
|
69
|
-
dockerfile_path = File.expand_path("./
|
|
70
|
+
dockerfile_path = File.expand_path("./Tests.dockerfile", root_dir)
|
|
70
71
|
fingerprintable_strings = [
|
|
71
72
|
File.read(gemfile_lock_path),
|
|
72
73
|
File.read(dockerfile_path),
|
data/utilities/utilities.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}")
|