Skip to content

Commit c5e8a88

Browse files
fpseverino0xTim
andauthored
Use project name as executable target name (#152)
* Use project name as executable target name * Fix dynamic test file naming in manifest.yml --------- Co-authored-by: Tim Condon <[email protected]>
1 parent f16688d commit c5e8a88

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ COPY . .
2626
# Build the application, with optimizations, with static linking, and using jemalloc
2727
# N.B.: The static version of jemalloc is incompatible with the static Swift runtime.
2828
RUN swift build -c release \
29-
--product App \
29+
--product {{name}} \
3030
--static-swift-stdlib \
3131
-Xlinker -ljemalloc
3232

3333
# Switch to the staging area
3434
WORKDIR /staging
3535

3636
# Copy main executable to staging area
37-
RUN cp "$(swift build --package-path /build -c release --show-bin-path)/App" ./
37+
RUN cp "$(swift build --package-path /build -c release --show-bin-path)/{{name}}" ./
3838

3939
# Copy static swift backtracer binary to staging area
4040
RUN cp "/usr/libexec/swift/linux/swift-backtrace-static" ./
@@ -85,5 +85,5 @@ USER vapor:vapor
8585
EXPOSE 8080
8686

8787
# Start the Vapor service when the image is run, default to listening on 8080 in production environment
88-
ENTRYPOINT ["./App"]
88+
ENTRYPOINT ["./{{name}}"]
8989
CMD ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"]

Package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let package = Package(
2020
],
2121
targets: [
2222
.executableTarget(
23-
name: "App",
23+
name: "{{name}}",
2424
dependencies: [{{#fluent}}
2525
.product(name: "Fluent", package: "fluent"),
2626
.product(name: "Fluent{{fluent.db.module}}Driver", package: "fluent-{{fluent.db.url}}-driver"),{{/fluent}}{{#leaf}}
@@ -32,9 +32,9 @@ let package = Package(
3232
swiftSettings: swiftSettings
3333
),
3434
.testTarget(
35-
name: "AppTests",
35+
name: "{{name}}Tests",
3636
dependencies: [
37-
.target(name: "App"),
37+
.target(name: "{{name}}"),
3838
.product(name: "VaporTesting", package: "vapor"),
3939
],
4040
swiftSettings: swiftSettings

Tests/AppTests/AppTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testable import App
1+
@testable import {{name}}
22
import VaporTesting
33
import Testing
44
{{#fluent}}import Fluent
@@ -7,7 +7,7 @@ import Testing
77
{{#fluent}}@Suite("App Tests with DB", .serialized)
88
{{/fluent}}{{^fluent}}@Suite("App Tests")
99
{{/fluent}}
10-
struct AppTests {
10+
struct {{name}}Tests {
1111
private func withApp(_ test: (Application) async throws -> ()) async throws {
1212
let app = try await Application.make(.testing)
1313
do {

manifest.yml

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ files:
4444
- folder: Sources
4545
files:
4646
- folder: App
47+
dynamic_name: "{{name}}"
4748
files:
4849
- file: entrypoint.swift
4950
- file: configure.swift
@@ -70,8 +71,10 @@ files:
7071
- folder: Tests
7172
files:
7273
- folder: AppTests
74+
dynamic_name: "{{name}}Tests"
7375
files:
7476
- file: AppTests.swift
77+
dynamic_name: "{{name}}Tests.swift"
7578
dynamic: true
7679
- folder: Resources
7780
if: leaf

0 commit comments

Comments
 (0)