diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..73ce950 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +5.2.4 diff --git a/Package.resolved b/Package.resolved index cf3af8f..6640bcb 100644 --- a/Package.resolved +++ b/Package.resolved @@ -47,12 +47,12 @@ } }, { - "package": "SKQueue", - "repositoryURL": "https://github.com/MaxDesiatov/SKQueue.git", + "package": "ShellOut", + "repositoryURL": "https://github.com/JohnSundell/ShellOut.git", "state": { - "branch": "master", - "revision": "448a61e772c5beb60ab035b2af140e3165f71b23", - "version": null + "branch": null, + "revision": "e1577acf2b6e90086d01a6d5e2b8efdaae033568", + "version": "2.3.0" } }, { @@ -136,6 +136,15 @@ "version": "2.7.1" } }, + { + "package": "swift-tools-support-core", + "repositoryURL": "https://github.com/apple/swift-tools-support-core.git", + "state": { + "branch": null, + "revision": "912919ab8441306c86c514b78800e4498ab60b60", + "version": "0.1.3" + } + }, { "package": "vapor", "repositoryURL": "https://github.com/vapor/vapor.git", diff --git a/Package.swift b/Package.swift index ca8d7a3..dfe0d85 100644 --- a/Package.swift +++ b/Package.swift @@ -9,9 +9,10 @@ let package = Package( dependencies: [ .package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "0.0.5")), .package(url: "https://github.com/vapor/vapor.git", from: "4.5.0"), - .package(url: "https://github.com/MaxDesiatov/SKQueue.git", .branch("master")), + .package(url: "https://github.com/apple/swift-tools-support-core.git", .upToNextMinor(from: "0.1.3")), .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.1.1"), - .package(url: "https://github.com/NSHipster/HypertextLiteral", from: "0.0.1"), + .package(url: "https://github.com/NSHipster/HypertextLiteral", .upToNextMinor(from: "0.0.1")), + .package(url: "https://github.com/JohnSundell/ShellOut.git", from: "2.3.0"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. @@ -22,8 +23,9 @@ let package = Package( .product(name: "ArgumentParser", package: "swift-argument-parser"), .product(name: "Vapor", package: "vapor"), .product(name: "AsyncHTTPClient", package: "async-http-client"), - "SKQueue", + .product(name: "SwiftToolsSupport", package: "swift-tools-support-core"), "HypertextLiteral", + "ShellOut", ] ), .testTarget( diff --git a/Sources/carton/Dev.swift b/Sources/carton/Dev.swift index 888ebd2..e5ccc2d 100644 --- a/Sources/carton/Dev.swift +++ b/Sources/carton/Dev.swift @@ -1,4 +1,38 @@ import ArgumentParser +import Foundation +import ShellOut + +struct ProductType: Codable { + let executable: String? + let library: [String] +} + +/** + Simple Product structure from package dump + */ +struct Product: Codable { + let name: String + let type: ProductType +} + +/** + Simple Package structure from package dump + */ +struct Package: Codable { + let name: String + let products: [Product] + let targets: [Target] +} + +enum TargetType: String, Codable { + case regular + case test +} + +struct Target: Codable { + let name: String + let type: TargetType +} struct Dev: ParsableCommand { static var configuration = CommandConfiguration( @@ -6,6 +40,10 @@ struct Dev: ParsableCommand { ) func run() throws { + let output = try shellOut(to: "swift", arguments: ["package", "dump-package"]) + guard let data = output.data(using: .utf8) + else { fatalError("failed to decode `swift package dump-package` output") } + try print(JSONDecoder().decode(Package.self, from: data)) try Server.run() } } diff --git a/TestApp/.swift-version b/TestApp/.swift-version index 5b21a21..51d3452 100644 --- a/TestApp/.swift-version +++ b/TestApp/.swift-version @@ -1 +1 @@ -wasm-DEVELOPMENT-SNAPSHOT-2020-05-02-a +wasm-DEVELOPMENT-SNAPSHOT-2020-05-25-a diff --git a/TestApp/Package.resolved b/TestApp/Package.resolved index e87bb2f..6f4bea8 100644 --- a/TestApp/Package.resolved +++ b/TestApp/Package.resolved @@ -5,9 +5,9 @@ "package": "JavaScriptKit", "repositoryURL": "https://github.com/kateinoigakukun/JavaScriptKit", "state": { - "branch": null, - "revision": "1edcf707dcb06f50e980c6cac542f226361dc124", - "version": "0.3.0" + "branch": "b245ad5", + "revision": "b245ad5a2c1c4f5e519900ff06d845cbc106378a", + "version": null } } ] diff --git a/TestApp/Package.swift b/TestApp/Package.swift index a670d97..699b876 100644 --- a/TestApp/Package.swift +++ b/TestApp/Package.swift @@ -5,8 +5,11 @@ import PackageDescription let package = Package( name: "CartonTestApp", + products: [ + .executable(name: "TestApp", targets: ["TestApp"]), + ], dependencies: [ - .package(url: "https://github.com/kateinoigakukun/JavaScriptKit", from: "0.3.0"), + .package(url: "https://github.com/kateinoigakukun/JavaScriptKit", .revision("b245ad5")), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite.