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

Improved extension build output #1737

Merged
merged 2 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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