Skip to content

Commit

Permalink
Cleanup server logs
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewBarba committed Jan 9, 2024
1 parent 78e3db5 commit 2e1defb
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions Plugins/VercelPackager/VercelOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,11 @@ public struct VercelOutput {
)

Task {
var env = localEnvironment()
env["LOCAL_LAMBDA_SERVER_ENABLED"] = "true"

try Shell.execute(
executable: context.tool(named: "swift").path,
arguments: ["run", "--package-path", projectDirectory.string],
environment: env
)
try startSwiftAppServer()
}

Task {
try await proxyServer()
try startNodeProxyServer()
}

try await Task.sleep(nanoseconds: 3_000_000_000)
Expand All @@ -124,15 +117,7 @@ public struct VercelOutput {
print("")
print("")

try Shell.execute(
executable: context.tool(named: "node").path,
arguments: [
projectDirectory.appending([".build", "checkouts", "Vercel", "Plugins", "VercelPackager", "Server", "server.cjs"]).string,
port
],
environment: ["SWIFT_PROJECT_DIRECTORY": projectDirectory.string],
printCommand: false
)
try startNodeProxyServer()
}
}

Expand Down Expand Up @@ -487,6 +472,34 @@ extension VercelOutput {
}
}

// MARK: - Server

extension VercelOutput {

public func startSwiftAppServer() throws {
var env = localEnvironment()
env["LOCAL_LAMBDA_SERVER_ENABLED"] = "true"

try Shell.execute(
executable: context.tool(named: "swift").path,
arguments: ["run", "--package-path", projectDirectory.string],
environment: env
)
}

public func startNodeProxyServer() throws {
try Shell.execute(
executable: context.tool(named: "node").path,
arguments: [
projectDirectory.appending([".build", "checkouts", "Vercel", "Plugins", "VercelPackager", "Server", "server.cjs"]).string,
port
],
environment: ["SWIFT_PROJECT_DIRECTORY": projectDirectory.string],
printCommand: false
)
}
}

// MARK: - Build

extension VercelOutput {
Expand Down

0 comments on commit 2e1defb

Please sign in to comment.