|
1 | | -// swift-tools-version:5.0 |
| 1 | +// swift-tools-version:6.2 |
2 | 2 | // |
3 | 3 | // Package.swift |
4 | 4 | // SwiftObjects |
5 | 5 | // |
6 | 6 | // Created by Helge Hess on 11.05.18. |
7 | | -// Copyright © 2018-2020 ZeeZide. All rights reserved. |
| 7 | +// Copyright © 2018-2026 ZeeZide. All rights reserved. |
8 | 8 | // |
9 | 9 | import PackageDescription |
| 10 | +import Foundation |
| 11 | + |
| 12 | +let fm = FileManager.default |
10 | 13 |
|
11 | 14 | let package = Package( |
12 | | - name: "SwiftObjects", |
| 15 | + name: "SwiftObjects", |
| 16 | + |
| 17 | + platforms: [ .macOS(.v15), .iOS(.v18), .visionOS(.v2) ], |
| 18 | + |
| 19 | + products: [ |
| 20 | + .library(name: "SwiftObjects", targets: [ "SwiftObjects" ]), |
| 21 | + ], |
| 22 | + |
| 23 | + dependencies: [ |
| 24 | + .package(url: "https://github.com/apple/swift-nio.git", |
| 25 | + from: "2.92.1"), |
| 26 | + .package(url: "https://github.com/wickwirew/Runtime.git", |
| 27 | + from: "2.2.7"), |
13 | 28 |
|
14 | | - products: [ |
15 | | - .library(name: "SwiftObjects", targets: [ "SwiftObjects" ]), |
16 | | - ], |
17 | | - |
18 | | - dependencies: [ |
19 | | - .package(url: "https://github.com/apple/swift-nio.git", |
20 | | - from: "2.25.1"), |
21 | | - .package(url: "https://github.com/wickwirew/Runtime.git", |
22 | | - from: "2.2.2"), |
23 | | - |
24 | | - // just for the showcase |
25 | | - .package(url: "https://github.com/SwiftWebResources/SemanticUI-Swift.git", |
26 | | - from: "2.4.2"), |
27 | | - .package(url: "https://github.com/SwiftWebResources/jQuery-Swift.git", |
28 | | - from: "3.5.1"), |
29 | | - ], |
| 29 | + // just for the showcase |
| 30 | + .package(url: "https://github.com/SwiftWebResources/SemanticUI-Swift.git", |
| 31 | + from: "2.5.0"), |
| 32 | + .package(url: "https://github.com/SwiftWebResources/jQuery-Swift.git", |
| 33 | + from: "3.7.1"), |
| 34 | + ], |
| 35 | + |
| 36 | + targets: [ |
| 37 | + .target(name: "SwiftObjects", |
| 38 | + dependencies: [ |
| 39 | + .product(name: "NIO", package: "swift-nio"), |
| 40 | + .product(name: "NIOHTTP1", package: "swift-nio"), |
| 41 | + .product(name: "NIOFoundationCompat", package: "swift-nio"), |
| 42 | + .product(name: "Runtime", package: "Runtime"), |
| 43 | + ], |
| 44 | + exclude: |
| 45 | + fm.filesWithExtension("api", at: targetURL("SwiftObjects")), |
| 46 | + swiftSettings: [ .swiftLanguageMode(.v5) ]), |
| 47 | + |
| 48 | + .testTarget(name: "SwiftObjectsTests", |
| 49 | + dependencies: [ "SwiftObjects" ], |
| 50 | + swiftSettings: [ .swiftLanguageMode(.v5) ]), |
| 51 | + |
| 52 | + .executableTarget(name: "WOShowcaseApp", |
| 53 | + dependencies: [ |
| 54 | + "SwiftObjects", |
| 55 | + .product(name: "SemanticUI", |
| 56 | + package: "SemanticUI-Swift"), |
| 57 | + .product(name: "jQuery", package: "jQuery-Swift") |
| 58 | + ], |
| 59 | + resources: [ |
| 60 | + .copy("favicon.ico") |
| 61 | + ] |
| 62 | + + fm.filesWithExtension("html", |
| 63 | + at: targetURL("WOShowcaseApp")) |
| 64 | + .map { .copy($0) } |
| 65 | + + fm.filesWithExtension("wod", |
| 66 | + at: targetURL("WOShowcaseApp")) |
| 67 | + .map { .copy($0) }) |
| 68 | + ] |
| 69 | +) |
30 | 70 |
|
31 | | - targets: [ |
32 | | - .target(name: "SwiftObjects", |
33 | | - dependencies: [ |
34 | | - "NIO", |
35 | | - "NIOHTTP1", |
36 | | - "NIOFoundationCompat", |
37 | | - "NIOConcurrencyHelpers", |
38 | | - "Runtime" |
39 | | - ]), |
40 | | - .testTarget(name: "SwiftObjectsTests", |
41 | | - dependencies: [ "SwiftObjects" ]), |
| 71 | +fileprivate func targetURL(_ target: String) -> URL { |
| 72 | + URL(fileURLWithPath: #filePath) |
| 73 | + .deletingLastPathComponent() |
| 74 | + .appendingPathComponent("Sources") |
| 75 | + .appendingPathComponent(target) |
| 76 | +} |
42 | 77 |
|
43 | | - .target(name: "WOShowcaseApp", |
44 | | - dependencies: [ |
45 | | - "SwiftObjects", |
46 | | - "SemanticUI", |
47 | | - "jQuery" |
48 | | - ]), |
49 | | - ] |
50 | | -) |
| 78 | +fileprivate extension FileManager { |
| 79 | + |
| 80 | + func filesWithExtension(_ extension: String, at url: URL) -> [ String ] { |
| 81 | + let url = url.standardizedFileURL |
| 82 | + guard let enumerator = FileManager.default |
| 83 | + .enumerator(at: url, |
| 84 | + includingPropertiesForKeys: [ .isRegularFileKey ], |
| 85 | + options: [ .skipsHiddenFiles ]) |
| 86 | + else { return [] } |
| 87 | + |
| 88 | + let baseParts = url.pathComponents.count |
| 89 | + var files = [ String ]() |
| 90 | + for case let url as URL in enumerator |
| 91 | + where url.pathExtension == `extension` |
| 92 | + { |
| 93 | + let relative = url.pathComponents.dropFirst(baseParts) |
| 94 | + .joined(separator: "/") |
| 95 | + files.append(relative) |
| 96 | + } |
| 97 | + return files |
| 98 | + } |
| 99 | +} |
0 commit comments