Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Improved extension build output (#1737)
Browse files Browse the repository at this point in the history
ESBuild status messages and errors are now directly presented to the
user rather than being obfuscated by a generic message.

Co-authored-by: Gonzalo Riestra <gonzalo.riestra@shopify.com>
  • Loading branch information
2 people authored and Pedro Piñera committed Nov 23, 2021
1 parent 7f7499e commit e8f47f8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
11 changes: 3 additions & 8 deletions lib/project_types/extension/commands/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,16 @@ def self.help
private

def run_new_flow(project)
Tasks::RunExtensionCommand.new(
output = Tasks::RunExtensionCommand.new(
type: project.specification_identifier.downcase,
command: "build",
config_file_name: specification_handler.server_config_file,
context: @ctx,
).call

@ctx.puts(@ctx.message("build.build_success_message"))
@ctx.puts(output)
rescue => error
if error.message.include?("no such file or directory")
@ctx.abort(@ctx.message("build.directory_not_found"))
else
@ctx.debug(error)
@ctx.abort(@ctx.message("build.build_failure_message"))
end
raise ShopifyCLI::Abort, error.message
end

def run_legacy_flow
Expand Down
3 changes: 0 additions & 3 deletions lib/project_types/extension/messages/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ module Messages
Usage: {{command:%s extension build}}
HELP
frame_title: "Building extension with: %s…",
build_failure_message: "Failed to build extension code.",
build_success_message: "Build was successful!",
directory_not_found: "Build directory not found.",
},
register: {
help: <<~HELP,
Expand Down
4 changes: 2 additions & 2 deletions lib/project_types/extension/models/development_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def create(server_config)
end

def build(server_config)
_, error, status = CLI::Kit::System.capture3(executable, "build", "-", stdin_data: server_config.to_yaml)
return if status.success?
output, error, status = CLI::Kit::System.capture3(executable, "build", "-", stdin_data: server_config.to_yaml)
return output if status.success?
raise DevelopmentServerError, error
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ def test_build_calls_executable_and_is_successful

CLI::Kit::System.expects(:capture3)
.with(@development_server.executable, "build", "-", stdin_data: server_config.to_yaml)
.returns(["", nil, mock(success?: true)])
.returns(["some output", nil, mock(success?: true)])

@development_server.build(server_config)
output = @development_server.build(server_config)
assert_equal "some output", output
end
end

Expand Down

0 comments on commit e8f47f8

Please sign in to comment.