Skip to content

Commit

Permalink
User defined variables (#3)
Browse files Browse the repository at this point in the history
- allow user defined variables in the templates
- update to Swift 5.9 and package dep updates
- better swift-fromat support and makefile update
  • Loading branch information
tib authored Jan 17, 2024
1 parent 2acbba4 commit bcb0ce1
Show file tree
Hide file tree
Showing 19 changed files with 258 additions and 154 deletions.
58 changes: 58 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"indentation" : {
"spaces" : 4
},
"indentConditionalCompilationBlocks" : false,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : true,
"lineBreakBeforeControlFlowKeywords" : true,
"lineBreakBeforeEachArgument" : true,
"lineBreakBeforeEachGenericRequirement" : true,
"lineLength" : 80,
"maximumBlankLines" : 1,
"prioritizeKeepingFunctionOutputTogether" : false,
"respectsExistingLineBreaks" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : true,
"AlwaysUseLowerCamelCase" : false,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : false,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : false,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : false,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : false,
"ReturnVoidInsteadOfEmptyTuple" : true,
"UseEarlyExits" : false,
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : false,
"UseSynthesizedInitializer" : true,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : true
},
"spacesAroundRangeFormationOperators" : false,
"tabWidth" : 4,
"version" : 1
}
12 changes: 2 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,8 @@ install: release
uninstall:
rm /usr/local/bin/toucan

# swift-format commands

format:
@curl -s https://raw.githubusercontent.com/BinaryBirds/swift-format-template/main/config.json >> swift-format.json && \
swift-format --configuration swift-format.json -i -r ./Sources && \
swift-format --configuration swift-format.json -i -r ./Tests && \
rm -f ./swift-format.json
swift-format -i -r ./Sources && swift-format -i -r ./Tests

lint:
@curl -s https://raw.githubusercontent.com/BinaryBirds/swift-format-template/main/config.json >> swift-format.json && \
swift-format lint --configuration swift-format.json -r ./Sources && \
swift-format lint --configuration swift-format.json -r ./Tests && \
rm -f ./swift-format.json
swift-format lint -r ./Sources && swift-format lint -r ./Tests
83 changes: 55 additions & 28 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/BinaryBirds/file-manager-kit",
"state" : {
"branch" : "main",
"revision" : "3469a9b2d3204a78136e51557e684bccd3ad03e9"
"revision" : "3469a9b2d3204a78136e51557e684bccd3ad03e9",
"version" : "0.1.0"
}
},
{
Expand All @@ -23,17 +23,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/hummingbird-project/hummingbird",
"state" : {
"revision" : "a2b45b9aa5e09b1a2fa0a20b5dc3e9c208297d6a",
"version" : "1.5.1"
"revision" : "02ab65198bbf1b0c2c1087008f2c0f308d804dd5",
"version" : "1.12.0"
}
},
{
"identity" : "hummingbird-core",
"kind" : "remoteSourceControl",
"location" : "https://github.com/hummingbird-project/hummingbird-core.git",
"state" : {
"revision" : "4458f691653db58ac55a1aa8ef978709cd7e0749",
"version" : "1.3.1"
"revision" : "502abf07438b0d254ca8a28a50aab2ac5bca4599",
"version" : "1.6.0"
}
},
{
Expand All @@ -59,98 +59,125 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a",
"version" : "1.2.2"
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "6c89474e62719ddcc1e9614989fff2f68208fe10",
"version" : "1.1.0"
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-backtrace",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/swift-backtrace.git",
"state" : {
"revision" : "f25620d5d05e2f1ba27154b40cafea2b67566956",
"version" : "1.3.3"
"revision" : "80746bdd0ac8a7d83aad5d89dac3cbf15de652e6",
"version" : "1.3.4"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version" : "1.0.4"
"revision" : "d029d9d39c87bed85b1c50adee7c41795261a192",
"version" : "1.0.6"
}
},
{
"identity" : "swift-distributed-tracing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-distributed-tracing.git",
"state" : {
"revision" : "49b7617717a09f6b781c9a11e1628e3315d8d4fe",
"version" : "1.0.1"
}
},
{
"identity" : "swift-http-types",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"revision" : "1827dc94bdab2eb5f2fc804e9b0cb43574282566",
"version" : "1.0.2"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
"version" : "1.5.2"
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version" : "1.5.3"
}
},
{
"identity" : "swift-metrics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-metrics.git",
"state" : {
"revision" : "34025104068262db0cc998ace178975c5ff4f36b",
"version" : "2.4.0"
"revision" : "971ba26378ab69c43737ee7ba967a896cb74c0d1",
"version" : "2.4.1"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "6213ba7a06febe8fef60563a4a7d26a4085783cf",
"version" : "2.54.0"
"revision" : "702cd7c56d5d44eeba73fdf83918339b26dc855c",
"version" : "2.62.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "0e0d0aab665ff1a0659ce75ac003081f2b1c8997",
"version" : "1.19.0"
"revision" : "798c962495593a23fdea0c0c63fd55571d8dff51",
"version" : "1.20.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "a8ccf13fa62775277a5d56844878c828bbb3be1a",
"version" : "1.27.0"
"revision" : "3bd9004b9d685ed6b629760fc84903e48efec806",
"version" : "1.29.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "e866a626e105042a6a72a870c88b4c531ba05f83",
"version" : "2.24.0"
"revision" : "320bd978cceb8e88c125dcbb774943a92f6286e9",
"version" : "2.25.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "41f4098903878418537020075a4d8a6e20a0b182",
"version" : "1.17.0"
"revision" : "ebf8b9c365a6ce043bf6e6326a04b15589bd285e",
"version" : "1.20.0"
}
},
{
"identity" : "swift-service-context",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-service-context.git",
"state" : {
"revision" : "ce0141c8f123132dbd02fd45fea448018762df1b",
"version" : "1.0.0"
}
},
{
Expand Down
23 changes: 8 additions & 15 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// swift-tools-version:5.8
// swift-tools-version:5.9
import PackageDescription

let package = Package(
name: "toucan",
platforms: [
.macOS(.v10_15),
.macOS(.v12),
],
products: [
.executable(name: "toucan", targets: ["ToucanCli"]),
Expand All @@ -13,11 +13,11 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/hummingbird-project/hummingbird",
from: "1.5.0"
from: "1.12.0"
),
.package(
url: "https://github.com/apple/swift-argument-parser",
from: "1.2.0"
from: "1.3.0"
),
.package(
url: "https://github.com/JohnSundell/Ink",
Expand All @@ -27,14 +27,14 @@ let package = Package(
url: "https://github.com/JohnSundell/Splash",
from: "0.16.0"
),
.package(
url: "https://github.com/BinaryBirds/file-manager-kit",
from: "0.1.0"
),
.package(
url: "https://github.com/eonil/FSEvents",
branch: "master"
),
.package(
url: "https://github.com/BinaryBirds/file-manager-kit",
branch: "main"
)
],
targets: [
.target(name: "ToucanSDK", dependencies: [
Expand Down Expand Up @@ -70,14 +70,7 @@ let package = Package(
name: "EonilFSEvents",
package: "FSEvents"
),

.target(name: "ToucanSDK"),
],
swiftSettings: [
.unsafeFlags(
["-cross-module-optimization"],
.when(configuration: .release)
),
]
),

Expand Down
2 changes: 1 addition & 1 deletion Sources/ToucanCli/Commands/GenerateCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct GenerateCommand: ParsableCommand {

@Argument(help: "The output directory (default: docs).")
var output: String = "./docs"

@Option(name: .shortAndLong, help: "The base url to use.")
var baseUrl: String? = nil

Expand Down
6 changes: 4 additions & 2 deletions Sources/ToucanCli/Commands/ServeCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ extension HBApplication {
let currentPath = FileManager.default.currentDirectoryPath
workPath = currentPath + "/" + args.path
}

let url = URL(fileURLWithPath: workPath).standardized

print("🤖 Site preview available at: http://\(args.hostname):\(args.port)/ -> serving from: \(url.absoluteString) ")
print(
"🤖 Site preview available at: http://\(args.hostname):\(args.port)/ -> serving from: \(url.absoluteString) "
)

middleware.add(
HBFileMiddleware(
Expand Down
15 changes: 9 additions & 6 deletions Sources/ToucanCli/Commands/WatchCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ struct WatchCommand: ParsableCommand {

@Argument(help: "The output directory (default: docs).")
var output: String = "./docs"

@Option(name: .shortAndLong, help: "The base url to use.")
var baseUrl: String? = nil

func run() throws {
let toucan = Toucan(
inputPath: input,
Expand All @@ -36,12 +36,15 @@ struct WatchCommand: ParsableCommand {
print("Generating site...")
try? toucan.generate(baseUrl)
print("Site re-generated.")
})

}
)

eventStream.setDispatchQueue(DispatchQueue.main)

try eventStream.start()
print("👀 Watching: `\(toucan.inputUrl.path)` -> \(toucan.outputUrl.path).")
print(
"👀 Watching: `\(toucan.inputUrl.path)` -> \(toucan.outputUrl.path)."
)
dispatchMain()
}
}
Loading

0 comments on commit bcb0ce1

Please sign in to comment.