|
4 | 4 | import Foundation |
5 | 5 | import PackageDescription |
6 | 6 |
|
7 | | -// MARK: - Pro |
8 | | - |
9 | | -extension [Target.Dependency] { |
10 | | - func pro(_ targetNames: [String]) -> [Target.Dependency] { |
11 | | - if isProIncluded { |
12 | | - // include the pro package |
13 | | - return self + targetNames.map { Target.Dependency.product(name: $0, package: "Pro") } |
14 | | - } |
15 | | - return self |
16 | | - } |
17 | | -} |
18 | | - |
19 | | -extension [Package.Dependency] { |
20 | | - var pro: [Package.Dependency] { |
21 | | - if isProIncluded { |
22 | | - // include the pro package |
23 | | - return self + [.package(path: "../Pro/Pro")] |
24 | | - } |
25 | | - return self |
26 | | - } |
27 | | -} |
28 | | - |
29 | | -let isProIncluded: Bool = { |
30 | | - func isProIncluded(file: StaticString = #file) -> Bool { |
31 | | - let filePath = "\(file)" |
32 | | - let fileURL = URL(fileURLWithPath: filePath) |
33 | | - let rootURL = fileURL |
34 | | - .deletingLastPathComponent() |
35 | | - .deletingLastPathComponent() |
36 | | - let confURL = rootURL.appendingPathComponent("PLUS") |
37 | | - if !FileManager.default.fileExists(atPath: confURL.path) { |
38 | | - return false |
39 | | - } |
40 | | - do { |
41 | | - if let content = try String( |
42 | | - data: Data(contentsOf: confURL), |
43 | | - encoding: .utf8 |
44 | | - ) { |
45 | | - if content.hasPrefix("YES") { |
46 | | - return true |
47 | | - } |
48 | | - } |
49 | | - return false |
50 | | - } catch { |
51 | | - return false |
52 | | - } |
53 | | - } |
54 | | - |
55 | | - return isProIncluded() |
56 | | -}() |
57 | | - |
58 | 7 | // MARK: - Package |
59 | 8 |
|
60 | 9 | let package = Package( |
@@ -414,3 +363,40 @@ let package = Package( |
414 | 363 | ] |
415 | 364 | ) |
416 | 365 |
|
| 366 | +extension [Target.Dependency] { |
| 367 | + func pro(_ targetNames: [String]) -> [Target.Dependency] { |
| 368 | + if isProIncluded { |
| 369 | + // include the pro package |
| 370 | + return self + targetNames.map { Target.Dependency.product(name: $0, package: "Pro") } |
| 371 | + } |
| 372 | + return self |
| 373 | + } |
| 374 | +} |
| 375 | + |
| 376 | +extension [Package.Dependency] { |
| 377 | + var pro: [Package.Dependency] { |
| 378 | + if isProIncluded { |
| 379 | + // include the pro package |
| 380 | + return self + [.package(path: "../../CopilotForXcodePro/Pro")] |
| 381 | + } |
| 382 | + return self |
| 383 | + } |
| 384 | +} |
| 385 | + |
| 386 | +let isProIncluded: Bool = { |
| 387 | + func isProIncluded(file: StaticString = #file) -> Bool { |
| 388 | + let filePath = "\(file)" |
| 389 | + let fileURL = URL(fileURLWithPath: filePath) |
| 390 | + let rootURL = fileURL |
| 391 | + .deletingLastPathComponent() |
| 392 | + .deletingLastPathComponent() |
| 393 | + .deletingLastPathComponent() |
| 394 | + let confURL = rootURL.appendingPathComponent("PLUS") |
| 395 | + if !FileManager.default.fileExists(atPath: confURL.path) { |
| 396 | + return false |
| 397 | + } |
| 398 | + return true |
| 399 | + } |
| 400 | + |
| 401 | + return isProIncluded() |
| 402 | +}() |
0 commit comments