46 lines
1.4 KiB
Text
46 lines
1.4 KiB
Text
--!strict
|
|
local common = require("./common")
|
|
local progress_bar = require("@pkg/progress")
|
|
local result = require("@pkg/result")
|
|
|
|
export type ReplicatorData = {
|
|
remote_output: string,
|
|
replicator: string,
|
|
}
|
|
local function build(configuration: string, replicator_data: ReplicatorData?)
|
|
local progress = progress_bar.new():with_stage("init", "Initializing"):with_stage("build", "Building project")
|
|
if replicator_data then
|
|
progress:with_stage("replicate", "Replicating to remote server")
|
|
end
|
|
|
|
progress:start() -- init
|
|
|
|
progress:next_stage() -- build
|
|
|
|
local build_result = common.spawn(`dotnet build -c {configuration}`)
|
|
if not build_result.ok then
|
|
progress:stop()
|
|
return result(false, `Failed to build:\n{build_result.err}`)
|
|
end
|
|
|
|
if replicator_data then
|
|
progress:next_stage() -- replicate
|
|
|
|
progress:pause()
|
|
local replicator: common.Replicator = (require)(`./replicators/{replicator_data.replicator}`)
|
|
local replication_result = replicator(`src/bin/{configuration}/net8.0`, replicator_data.remote_output)
|
|
if not replication_result.ok then
|
|
progress:stop()
|
|
return result(false, `Failed to replicate build:\n{replication_result.err}`)
|
|
end
|
|
progress:unpause()
|
|
end
|
|
|
|
progress:stop() -- finish
|
|
|
|
print(build_result.val.stdout)
|
|
|
|
return result(true, nil)
|
|
end
|
|
|
|
return build
|