Skip to content

Commit

Permalink
fixup! Merge pull request #11 from brightdigit/v0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion committed Feb 4, 2025
1 parent cac8544 commit 27f6316
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Sources/PackageDSL/DependencyBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ public enum DependencyBuilder {

/// Builds a partial block of dependencies,
/// adding a new `Dependency` to an existing collection.
/// - Parameter accumulated: The existing collection of dependencies.
/// - Parameter next: The new `Dependency` to add to the collection.
/// - Parameters:
/// - accumulated: The existing collection of dependencies.
/// - next: The new `Dependency` to add to the collection.
/// - Returns: A new collection of dependencies,
/// containing the accumulated dependencies and the `next` dependency.
public static func buildPartialBlock(
Expand Down
3 changes: 3 additions & 0 deletions Sources/PackageDSL/FrontendFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
//

public protocol FrontendFlag: UnsafeFlag, _Named {
/// Arguments to pass to the unsafe flag with `-Xfrontend`
var flagArguments: [String] { get }
}

extension FrontendFlag {
/// Arguments to pass to the unsafe flag with `-Xfrontend`
public var flagArguments: [String] {
[name.camelToSnakeCaseFlag()]
}

/// The arguments for the unsafe flag.
public var unsafeFlagArguments: [String] {
["-Xfrontend", flagArguments.joined(separator: "=")]
}
Expand Down
1 change: 1 addition & 0 deletions Sources/PackageDSL/Package+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extension Package {
var pathComponents = #filePath.split(separator: "/")
pathComponents.removeLast()
// swift-format-ignore: NeverForceUnwrap
// swiftlint:disable:next force_unwrapping
return String(pathComponents.last!)
}

Expand Down
5 changes: 3 additions & 2 deletions Sources/PackageDSL/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ extension String {
func camelToSnakeCaseFlag(withSeparator separator: String = "-") -> String {
separator
+ enumerated()
.reduce("") {
$0 + ($1.offset > 0 && $1.element.isUppercase ? separator : "")
.reduce(into: "") {
$0 +=
($1.offset > 0 && $1.element.isUppercase ? separator : "")
+ String($1.element).lowercased()
}
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/PackageDSL/SwiftSettingFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
import PackageDescription

public protocol SwiftSettingFeature: _Named, SwiftSettingConvertible {
/// Whether this is experiemental or upcoming ``FeatureState``
var featureState: FeatureState { get }
}

extension SwiftSettingFeature {
/// Whether this is experiemental or upcoming ``FeatureState``
public var featureState: FeatureState {
.upcoming
}

/// The `SwiftSetting` represented by this type.
public var setting: SwiftSetting {
featureState.swiftSetting(name: name)
}
Expand Down
18 changes: 18 additions & 0 deletions Sources/PackageDSL/TestTargetBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,41 @@
// Licensed under MIT License
//

/// Builds a collection ``TestTargets``
/// <#Description#>
@resultBuilder
public enum TestTargetBuilder {
/// Creates the ``TestTargets``
/// - Parameter first: A collection of ``TestTarget``
/// - Returns: ``TestTargets``
public static func buildPartialBlock(first: [any TestTarget]) -> any TestTargets {
first
}

/// Creates the ``TestTargets``
/// - Parameter first: A ``TestTarget``
/// - Returns: ``TestTargets``
public static func buildPartialBlock(first: any TestTarget) -> any TestTargets {
[first]
}

/// Creates the ``TestTargets``
/// - Parameters:
/// - accumulated: ``TestTargets``
/// - next: A ``TestTarget``
/// - Returns: New ``TestTargets
public static func buildPartialBlock(
accumulated: any TestTargets,
next: any TestTarget
) -> any TestTargets {
accumulated + [next]
}

/// Creates the ``TestTargets``
/// - Parameters:
/// - accumulated: ``TestTargets``
/// - next: A collection of ``TestTarget``
/// - Returns: New ``TestTargets``
public static func buildPartialBlock(
accumulated: any TestTargets,
next: any TestTargets
Expand Down
4 changes: 2 additions & 2 deletions Sources/PackageDSL/_Named.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Licensed under MIT License
//

// swiftlint:disable type_name
// swiftlint:disable type_name missing_docs

// swift-format-ignore: NoLeadingUnderscores
public protocol _Named {
Expand All @@ -16,4 +16,4 @@ extension _Named {
"\(Self.self)"
}
}
// swiftlint:enable type_name
// swiftlint:enable type_name missing_docs

0 comments on commit 27f6316

Please sign in to comment.