Skip to content

Commit

Permalink
Merge pull request #31 from Ether-CLI/develop
Browse files Browse the repository at this point in the history
2018.08.11
  • Loading branch information
calebkleveter committed Aug 11, 2018
2 parents 64232f1 + 528950b commit 0cb6d26
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 36 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [2018.08.11]

### Fixed
- `new` command no longer fails when cleaning new project's manifest.
- Dependency writing when last dependency has a trailing comma.
- White space when adding first dependency to manifest.

### Added
-

## [2018.06.15]

### Added
Expand Down
83 changes: 55 additions & 28 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"object": {
"pins": [
{
"package": "Console",
"repositoryURL": "https://github.com/vapor/console.git",
"package": "AEXML",
"repositoryURL": "https://github.com/tadija/AEXML.git",
"state": {
"branch": null,
"revision": "5b9796d39f201b3dd06800437abd9d774a455e57",
"version": "3.0.2"
"revision": "6eea665515d079c338690147082a8084a36484b0",
"version": "4.3.0"
}
},
{
"package": "Core",
"repositoryURL": "https://github.com/vapor/core.git",
"state": {
"branch": null,
"revision": "e5582911ed940289212a36321e15ec561d947dbe",
"version": "3.3.0"
"revision": "7f56a09995bf3c8df562be456bdcda405d9d0678",
"version": "3.4.1"
}
},
{
Expand All @@ -33,8 +33,8 @@
"repositoryURL": "https://github.com/vapor/database-kit.git",
"state": {
"branch": null,
"revision": "4ac3e7437f9b95ce32b4d970bafa590bb3579647",
"version": "1.1.0"
"revision": "7a01659316b9f033fa2150d5cd5e9d3c3e46c2e3",
"version": "1.3.0"
}
},
{
Expand All @@ -51,17 +51,26 @@
"repositoryURL": "https://github.com/Ether-CLI/Manifest.git",
"state": {
"branch": null,
"revision": "a200f9a6af998f787ac4ea7b92802f7b139d499f",
"version": "0.4.5"
"revision": "21cf15c2ce50a630aed3a7d353c77d3a6dc953b1",
"version": "0.4.6"
}
},
{
"package": "Multipart",
"repositoryURL": "https://github.com/vapor/multipart.git",
"state": {
"branch": null,
"revision": "7778dcb62f3efa845e8e2808937bb347575ba7ce",
"version": "3.0.1"
"revision": "e57007c23a52b68e44ebdfc70cbe882a7c4f1ec3",
"version": "3.0.2"
}
},
{
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit.git",
"state": {
"branch": null,
"revision": "fa81fa9e3a9f59645159c4ea45c0c46ee6558f71",
"version": "0.9.1"
}
},
{
Expand All @@ -74,30 +83,39 @@
}
},
{
"package": "Service",
"repositoryURL": "https://github.com/vapor/service.git",
"package": "ShellOut",
"repositoryURL": "https://github.com/JohnSundell/ShellOut.git",
"state": {
"branch": null,
"revision": "281a70b69783891900be31a9e70051b6fe19e146",
"version": "1.0.0"
"revision": "f1c253a34a40df4bfd268b09fdb101b059f6d52d",
"version": "2.1.0"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "e34d5687e1e9d865e3527dd58bc2f7464ef6d936",
"version": "0.8.0"
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
"state": {
"branch": null,
"revision": "695afc5205aaa49fca092b94b479ff71c43d9d3c",
"version": "1.8.0"
"revision": "cf08e673dc41dc63d34065234c8fc432e8d334c4",
"version": "1.9.2"
}
},
{
"package": "swift-nio-ssl",
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git",
"state": {
"branch": null,
"revision": "0adc938bc8de3d3829b842f9767d81c7480b8403",
"version": "1.1.1"
"revision": "6617eb0d3afcb12170594968df01ca63afb58ac5",
"version": "1.2.0"
}
},
{
Expand All @@ -123,35 +141,35 @@
"repositoryURL": "https://github.com/vapor/template-kit.git",
"state": {
"branch": null,
"revision": "43b57b5861d5181b906ac6411d28645e980bb638",
"version": "1.0.1"
"revision": "db35b1c35aabd0f5db3abca0cfda7becfe9c43e2",
"version": "1.1.0"
}
},
{
"package": "URLEncodedForm",
"repositoryURL": "https://github.com/vapor/url-encoded-form.git",
"state": {
"branch": null,
"revision": "57cf7fb9c1a1014c50bc05123684a9139ad44127",
"version": "1.0.3"
"revision": "cbfe7ef6301557d3f2d0807a98165232ae06e1c6",
"version": "1.0.4"
}
},
{
"package": "Validation",
"repositoryURL": "https://github.com/vapor/validation.git",
"state": {
"branch": null,
"revision": "ab6c5a352d97c8687b91ed4963aef8e7cfe0795b",
"version": "2.0.0"
"revision": "156f8adeac3440e868da3757777884efbc6ec0cc",
"version": "2.1.0"
}
},
{
"package": "Vapor",
"repositoryURL": "https://github.com/vapor/vapor.git",
"state": {
"branch": null,
"revision": "09faa90db7ca49d7f75d5f8e385abce93bc7afb3",
"version": "3.0.4"
"revision": "54632a6c1e7ecd9923c0d00b612de936de1c4745",
"version": "3.0.8"
}
},
{
Expand All @@ -162,6 +180,15 @@
"revision": "141cb4d3814dc8062cb0b2f43e72801b5dfcf272",
"version": "1.0.1"
}
},
{
"package": "xcproj",
"repositoryURL": "https://github.com/tuist/xcodeproj.git",
"state": {
"branch": null,
"revision": "e787c68092e28fe2b34205fc1b62de431922c243",
"version": "4.3.0"
}
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ let package = Package(
.library(name: "Ether", targets: ["Helpers", "Ether"])
],
dependencies: [
.package(url: "https://github.com/tuist/xcodeproj.git", from: "4.3.0"),
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.3"),
.package(url: "https://github.com/vapor/console.git", from: "3.0.2"),
.package(url: "https://github.com/vapor/core.git", from: "3.1.7"),
.package(url: "https://github.com/Ether-CLI/Manifest.git", from: "0.4.4")
],
targets: [
.target(name: "Helpers", dependencies: ["Core", "Console"]),
.target(name: "Ether", dependencies: ["Vapor", "Helpers", "Console", "Command", "Manifest", "Core"]),
.target(name: "Ether", dependencies: ["Vapor", "Helpers", "Console", "Command", "Manifest", "Core", "xcproj"]),
.target(name: "Executable", dependencies: ["Vapor", "Ether", "Console"])
]
)
20 changes: 16 additions & 4 deletions Sources/Ether/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,43 @@ public class Configuration: Command {
CommandArgument.argument(name: "value", help: ["The new value for the key passed in. If no value is passed in, the key will be removed from the config"])
]

public var options: [CommandOption] = []
public var options: [CommandOption] = [
CommandOption.flag(name: "print", short: "p", help: ["Outputs config key value. 'value' argument must have a value passed in, but it will not be used."])
]

public var help: [String] = ["Configure custom actions to occure when a command is run"]

public init() {}

public func run(using context: CommandContext) throws -> EventLoopFuture<Void> {
let setter = context.console.loadingBar(title: "Setting Configuration Key")
_ = setter.start(on: context.container)

let shouldPrint = context.options["print"] != nil
let key = try context.argument("key")
let value = context.arguments["value"]
let user = try Process.execute("whoami")

if !shouldPrint {
_ = setter.start(on: context.container)
}

var configuration = try Configuration.get()

guard let property = Config.properties[key] else {
throw EtherError(identifier: "noSettingWithName", reason: "No configuration setting found with name '\(key)'")
}

configuration[keyPath: property] = value
if shouldPrint {
context.console.print(configuration[keyPath: property] ?? "nil")
} else {
configuration[keyPath: property] = value
}

try JSONEncoder().encode(configuration).write(to: URL(string: "file:/Users/\(user)/Library/Application%20Support/Ether/config.json")!)

setter.succeed()
if !shouldPrint {
setter.succeed()
}
return context.container.eventLoop.newSucceededFuture(result: ())
}

Expand Down
7 changes: 5 additions & 2 deletions Sources/Ether/New.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public final class New: Command {
let script = "mkdir \(name); cd \(name); swift package init --type=executable"
_ = try Process.execute("bash", ["-c", script])

try Manifest.current.reset()
let currentDir = try Process.execute("pwd")
try Manifest(path: "file:\(currentDir)/\(name)/Package.swift").reset()
return true
}
return false
Expand Down Expand Up @@ -88,6 +89,8 @@ public final class New: Command {
let name = try context.argument("name")
let script = "mkdir \(name); cd \(name); swift package init"
_ = try Process.execute("bash", ["-c", script])
try Manifest.current.reset()

let currentDir = try Process.execute("pwd")
try Manifest(path: "file:\(currentDir)/\(name)/Package.swift").reset()
}
}

0 comments on commit 0cb6d26

Please sign in to comment.