From 72586c5c7e94759905f960d2c97bbe8ffa8dd5d6 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Mon, 22 Jan 2018 17:30:55 -0600 Subject: [PATCH 01/19] Created basic VersonSet console command --- Sources/Ether/VersionSet.swift | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Sources/Ether/VersionSet.swift diff --git a/Sources/Ether/VersionSet.swift b/Sources/Ether/VersionSet.swift new file mode 100644 index 0000000..61706ff --- /dev/null +++ b/Sources/Ether/VersionSet.swift @@ -0,0 +1,38 @@ +// The MIT License (MIT) +// +// Copyright (c) 2017 Caleb Kleveter +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +import Console +import Helpers + +public final class VersonSet: Command { + public let id: String = "set" + + public let console: ConsoleProtocol + + public init(console: ConsoleProtocol) { + self.console = console + } + + public func run(arguments: [String]) throws { + + } +} From 962d720aff7d103d2c9efbc1c2560199f4dfbb37 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Mon, 22 Jan 2018 17:44:52 -0600 Subject: [PATCH 02/19] Implimented VersionSet.signiture array --- Sources/Ether/VersionSet.swift | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Sources/Ether/VersionSet.swift b/Sources/Ether/VersionSet.swift index 61706ff..ed99117 100644 --- a/Sources/Ether/VersionSet.swift +++ b/Sources/Ether/VersionSet.swift @@ -26,6 +26,33 @@ import Helpers public final class VersonSet: Command { public let id: String = "set" + public var signature: [Argument] = [ + Value(name: "name", help: [ + "The name of the package to change the version for (case insensative)" + ]), + Value(name: "verson", help: [ + "The value for the new version. The format varies depending on the version type used" + ]), + Option(name: "from", short: "f", help: [ + "Sets the dependency version argument to `from: VERSION`" + ]), + Option(name: "up-to-next-major", short: "u", help: [ + "Sets the dependency version argument to `.upToNextMinor(from: \"VERSION\")`" + ]), + Option(name: "exact", short: "e", help: [ + "Sets the dependency version argument to `.exact(\"VERSION\")`" + ]), + Option(name: "range", short: "r", help: [ + "Sets the dependency version argument to `VERSION`" + ]), + Option(name: "branch", short: "b", help: [ + "Sets the dependency version argument to `.branch(\"VERSION\")`" + ]), + Option(name: "revision", help: [ + "Sets the dependency version argument to `.revision(\"VERSION\")`" + ]) + ] + public let console: ConsoleProtocol public init(console: ConsoleProtocol) { From c8108e1c2ce9128f1555dc511b460d8a5b60c2bf Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Mon, 22 Jan 2018 17:46:06 -0600 Subject: [PATCH 03/19] Implimented VersionSet.help array --- Sources/Ether/VersionSet.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/Ether/VersionSet.swift b/Sources/Ether/VersionSet.swift index ed99117..614845b 100644 --- a/Sources/Ether/VersionSet.swift +++ b/Sources/Ether/VersionSet.swift @@ -53,6 +53,10 @@ public final class VersonSet: Command { ]) ] + public var help: [String] = [ + "Changes the version of a single dependency" + ] + public let console: ConsoleProtocol public init(console: ConsoleProtocol) { From 11d20b47ec89c138f2618e46c56558a5f4e1624c Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Mon, 22 Jan 2018 18:01:22 -0600 Subject: [PATCH 04/19] Created VeriableSet.versionOption private method --- Sources/Ether/VersionSet.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sources/Ether/VersionSet.swift b/Sources/Ether/VersionSet.swift index 614845b..e7c5654 100644 --- a/Sources/Ether/VersionSet.swift +++ b/Sources/Ether/VersionSet.swift @@ -66,4 +66,19 @@ public final class VersonSet: Command { public func run(arguments: [String]) throws { } + + private func versionOption(from arguments: [String], with version: String) -> String { + if arguments.option("from") != nil { + return "from: \"\(version)\"" + } else if arguments.option("up-to-next-major") != nil { + return ".upToNextMajor(from: \"\(version)\")" + } else if arguments.option("range") != nil { + return "\(version.dropLast(8))\(String(version.dropFirst(5)).dropLast(5))\(version.dropFirst(8))" + } else if arguments.option("branch") != nil { + return ".branch(\"\(version)\")" + } else if arguments.option("revision") != nil { + return ".revision(\"\(version)\")" + } + return ".exact(\"\(version)\")" + } } From d5cfa0e1359b699a79db2b059c537ca34d4ea215 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Wed, 24 Jan 2018 16:27:29 -0600 Subject: [PATCH 05/19] Added quotes to version range from VersionSet.versionOption --- Sources/Ether/VersionSet.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Ether/VersionSet.swift b/Sources/Ether/VersionSet.swift index e7c5654..7b3f69c 100644 --- a/Sources/Ether/VersionSet.swift +++ b/Sources/Ether/VersionSet.swift @@ -73,7 +73,7 @@ public final class VersonSet: Command { } else if arguments.option("up-to-next-major") != nil { return ".upToNextMajor(from: \"\(version)\")" } else if arguments.option("range") != nil { - return "\(version.dropLast(8))\(String(version.dropFirst(5)).dropLast(5))\(version.dropFirst(8))" + return "\"\(version.dropLast(8))\"\(String(version.dropFirst(5)).dropLast(5))\"\(version.dropFirst(8))\"" } else if arguments.option("branch") != nil { return ".branch(\"\(version)\")" } else if arguments.option("revision") != nil { From 91198a75a4c03afdd0e92b9055c359aed87ec6fe Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Tue, 13 Feb 2018 17:00:00 -0600 Subject: [PATCH 06/19] Set Swift version to 4.1 --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 4d54dad..8a36cd1 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.0.2 +4.1 \ No newline at end of file From 9416c6784676e0b39f796cf89b9bc7dcd2c9565d Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Tue, 13 Feb 2018 17:00:34 -0600 Subject: [PATCH 07/19] Fixed documentation for Manifest.getPackageUrl method --- Sources/Helpers/Manifest.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Helpers/Manifest.swift b/Sources/Helpers/Manifest.swift index ba51a1e..b4ff0e6 100644 --- a/Sources/Helpers/Manifest.swift +++ b/Sources/Helpers/Manifest.swift @@ -99,7 +99,7 @@ public class Manifest { return name } - /// Gets the name of the package that has a specefied URL by reading the `Package.resolved` file data. + /// Gets the URL of the package that has a specefied name by reading the `Package.resolved` file data. /// /// - Parameter name: The ame of the package that the URL is to get fetched from. /// - Returns: The URL of the package that was found. From 6099ebe67fe59debc62e56b0762bc8a2ddcecf09 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Tue, 13 Feb 2018 17:01:01 -0600 Subject: [PATCH 08/19] Started implementing VersionSet.run method --- Sources/Ether/VersionSet.swift | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Sources/Ether/VersionSet.swift b/Sources/Ether/VersionSet.swift index 7b3f69c..9d08d96 100644 --- a/Sources/Ether/VersionSet.swift +++ b/Sources/Ether/VersionSet.swift @@ -22,15 +22,16 @@ import Console import Helpers +import Foundation public final class VersonSet: Command { public let id: String = "set" public var signature: [Argument] = [ Value(name: "name", help: [ - "The name of the package to change the version for (case insensative)" + "The name of the package to change the version for" ]), - Value(name: "verson", help: [ + Value(name: "version", help: [ "The value for the new version. The format varies depending on the version type used" ]), Option(name: "from", short: "f", help: [ @@ -64,7 +65,25 @@ public final class VersonSet: Command { } public func run(arguments: [String]) throws { + let package = try value("name", from: arguments) + let version = try value("version", from: arguments) + let versionLitteral = versionOption(from: arguments, with: version) + let url = try Manifest.current.getPackageUrl(for: package) + let manifest = try NSMutableString(string: Manifest.current.get()) + let pattern = try NSRegularExpression( + pattern: "(\\.package\\(url:\\s*\"\(url)\",\\s*)(.+?(?=\\),))(.*?\\n)", + options: [] + ) + let count = try pattern.matches(in: Manifest.current.get(), options: [], range: NSMakeRange(0, manifest.length)).count + console.output(""" + Count: \(count) + URL: \(url) + Reg: \("(\\.package\\(url:\\s*\"\(url)\",\\s*)(.+?(?=\\),))(.*?\\n)") + """, style: .plain, newLine: true) + pattern.replaceMatches(in: manifest, options: [], range: NSMakeRange(0, manifest.length), withTemplate: "$1\(versionLitteral)$3") + + try Manifest.current.write(String(manifest)) } private func versionOption(from arguments: [String], with version: String) -> String { From 4e8ac66d092cdded5d3d2c079b34bd5ce3a591de Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Tue, 13 Feb 2018 17:01:16 -0600 Subject: [PATCH 09/19] Added VersionSet command to main executable --- Sources/Executable/main.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/Executable/main.swift b/Sources/Executable/main.swift index 3f0663e..001bf53 100644 --- a/Sources/Executable/main.swift +++ b/Sources/Executable/main.swift @@ -57,7 +57,8 @@ do { FixInstall(console: terminal), Group(id: "version", commands: [ VersionLatest(console: terminal), - VersionAll(console: terminal) + VersionAll(console: terminal), + VersonSet(console: terminal) ], help: ["For interacting with dependency versions"]), CleanManifest(console: terminal) ] From 2d5eed2e5b3f544f975c8569169034dc28243d26 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Tue, 13 Feb 2018 17:04:07 -0600 Subject: [PATCH 10/19] Set Swift version to 4.1 --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 4d54dad..7d5c902 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.0.2 +4.1 From 00979145aea9437da3c1601a2c4d24dbc50719cf Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Tue, 13 Feb 2018 17:07:38 -0600 Subject: [PATCH 11/19] Removed use of --enable-prefetching flag --- Sources/Ether/FixInstall.swift | 6 +++--- Sources/Ether/Install.swift | 6 +++--- Sources/Ether/Remove.swift | 6 +++--- Sources/Ether/Update.swift | 8 ++++---- Sources/Ether/VersionLatest.swift | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Sources/Ether/FixInstall.swift b/Sources/Ether/FixInstall.swift index 99d0440..beec04a 100644 --- a/Sources/Ether/FixInstall.swift +++ b/Sources/Ether/FixInstall.swift @@ -48,11 +48,11 @@ public class FixInstall: Command { fixBar.start() _ = try console.backgroundExecute(program: "rm", arguments: ["-rf", ".build"]) - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "update"]) - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "resolve"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "update"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "resolve"]) if arguments.option("no-build") == nil { - _ = try console.backgroundExecute(program: "swift", arguments: ["build", "--enable-prefetching"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["build"]) } fixBar.finish() diff --git a/Sources/Ether/Install.swift b/Sources/Ether/Install.swift index dba290f..89d7eaf 100644 --- a/Sources/Ether/Install.swift +++ b/Sources/Ether/Install.swift @@ -111,8 +111,8 @@ public final class Install: Command { try String(mutablePackageManifest).data(using: .utf8)?.write(to: URL(string: "file:\(fileManager.currentDirectoryPath)/Package.swift")!) // Update the packages. - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "update"]) - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "resolve"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "update"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "resolve"]) // Get the new package name and add it to the previously accepted targets. let dependencyName = try Manifest.current.getPackageName(for: newPackageData.url) @@ -135,7 +135,7 @@ public final class Install: Command { if let _ = arguments.options["xcode"] { let xcodeBar = console.loadingBar(title: "Generating Xcode Project") xcodeBar.start() - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "generate-xcodeproj"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "generate-xcodeproj"]) xcodeBar.finish() try console.execute(program: "/bin/sh", arguments: ["-c", "open *.xcodeproj"], input: nil, output: nil, error: nil) } diff --git a/Sources/Ether/Remove.swift b/Sources/Ether/Remove.swift index 54ca389..c127b2c 100644 --- a/Sources/Ether/Remove.swift +++ b/Sources/Ether/Remove.swift @@ -69,8 +69,8 @@ public final class Remove: Command { do { try String(mutableString).data(using: .utf8)?.write(to: URL(string: "file:\(manager.currentDirectoryPath)/Package.swift")!) - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "update"]) - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "resolve"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "update"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "resolve"]) } catch let error { removingProgressBar.fail() throw error @@ -84,7 +84,7 @@ public final class Remove: Command { if let _ = arguments.options["xcode"] { let xcodeBar = console.loadingBar(title: "Generating Xcode Project") xcodeBar.start() - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "generate-xcodeproj"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "generate-xcodeproj"]) xcodeBar.finish() try console.execute(program: "/bin/sh", arguments: ["-c", "open *.xcodeproj"], input: nil, output: nil, error: nil) } diff --git a/Sources/Ether/Update.swift b/Sources/Ether/Update.swift index 52f75ec..edc1f3b 100644 --- a/Sources/Ether/Update.swift +++ b/Sources/Ether/Update.swift @@ -57,15 +57,15 @@ public final class Update: Command { let updateBar = console.loadingBar(title: "Updating Packages") updateBar.start() _ = try console.backgroundExecute(program: "rm", arguments: ["-rf", ".build"]) - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "update"]) - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "resolve"]) - _ = try console.backgroundExecute(program: "swift", arguments: ["build", "--enable-prefetching"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "update"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "resolve"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["build"]) updateBar.finish() if let _ = arguments.options["xcode"] { let xcodeBar = console.loadingBar(title: "Generating Xcode Project") xcodeBar.start() - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "generate-xcodeproj"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "generate-xcodeproj"]) xcodeBar.finish() try console.execute(program: "/bin/sh", arguments: ["-c", "open *.xcodeproj"], input: nil, output: nil, error: nil) } diff --git a/Sources/Ether/VersionLatest.swift b/Sources/Ether/VersionLatest.swift index c423c68..f0e4fb4 100644 --- a/Sources/Ether/VersionLatest.swift +++ b/Sources/Ether/VersionLatest.swift @@ -72,15 +72,15 @@ public final class VersionLatest: Command { } try String(nsManifest).data(using: .utf8)?.write(to: URL(string: "file:\(fileManager.currentDirectoryPath)/Package.swift")!) - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "update"]) - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "resolve"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "update"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "resolve"]) updateBar.finish() if let _ = arguments.options["xcode"] { let xcodeBar = console.loadingBar(title: "Generating Xcode Project") xcodeBar.start() - _ = try console.backgroundExecute(program: "swift", arguments: ["package", "--enable-prefetching", "generate-xcodeproj"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "generate-xcodeproj"]) xcodeBar.finish() try console.execute(program: "/bin/sh", arguments: ["-c", "open *.xcodeproj"], input: nil, output: nil, error: nil) } From d2f00f12cc1573eb4a4315a23d9f29f6f7ae6273 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Fri, 16 Feb 2018 17:18:35 -0600 Subject: [PATCH 12/19] Fixed RegEx for VersionSet to handle all package version types --- Sources/Ether/VersionSet.swift | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Sources/Ether/VersionSet.swift b/Sources/Ether/VersionSet.swift index 9d08d96..a9b3569 100644 --- a/Sources/Ether/VersionSet.swift +++ b/Sources/Ether/VersionSet.swift @@ -72,15 +72,9 @@ public final class VersonSet: Command { let url = try Manifest.current.getPackageUrl(for: package) let manifest = try NSMutableString(string: Manifest.current.get()) let pattern = try NSRegularExpression( - pattern: "(\\.package\\(url:\\s*\"\(url)\",\\s*)(.+?(?=\\),))(.*?\\n)", + pattern: "(\\,?\\n *\\.package\\(url: *\"\(url)\", *)(.*?)(\\),?\\n)", options: [] ) - let count = try pattern.matches(in: Manifest.current.get(), options: [], range: NSMakeRange(0, manifest.length)).count - console.output(""" - Count: \(count) - URL: \(url) - Reg: \("(\\.package\\(url:\\s*\"\(url)\",\\s*)(.+?(?=\\),))(.*?\\n)") - """, style: .plain, newLine: true) pattern.replaceMatches(in: manifest, options: [], range: NSMakeRange(0, manifest.length), withTemplate: "$1\(versionLitteral)$3") try Manifest.current.write(String(manifest)) From b5b8c10019444323c971a7302a41d1944064925c Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Fri, 16 Feb 2018 17:19:14 -0600 Subject: [PATCH 13/19] Specified exact version as the default package version type --- Sources/Ether/VersionSet.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Ether/VersionSet.swift b/Sources/Ether/VersionSet.swift index a9b3569..f4482f4 100644 --- a/Sources/Ether/VersionSet.swift +++ b/Sources/Ether/VersionSet.swift @@ -41,7 +41,7 @@ public final class VersonSet: Command { "Sets the dependency version argument to `.upToNextMinor(from: \"VERSION\")`" ]), Option(name: "exact", short: "e", help: [ - "Sets the dependency version argument to `.exact(\"VERSION\")`" + "(Default) Sets the dependency version argument to `.exact(\"VERSION\")`" ]), Option(name: "range", short: "r", help: [ "Sets the dependency version argument to `VERSION`" From 42a5615c49bf2d5d29c4b2df8fe9c70123a3a2c0 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Fri, 16 Feb 2018 17:19:43 -0600 Subject: [PATCH 14/19] Added loading bars, Xcode regeneration, and package update to VersionSet command --- Sources/Ether/VersionSet.swift | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Sources/Ether/VersionSet.swift b/Sources/Ether/VersionSet.swift index f4482f4..a75b746 100644 --- a/Sources/Ether/VersionSet.swift +++ b/Sources/Ether/VersionSet.swift @@ -34,6 +34,9 @@ public final class VersonSet: Command { Value(name: "version", help: [ "The value for the new version. The format varies depending on the version type used" ]), + Option(name: "xcode", short: "x", help: [ + "Regenerate the Xcode project after updating a package's version" + ]), Option(name: "from", short: "f", help: [ "Sets the dependency version argument to `from: VERSION`" ]), @@ -65,6 +68,9 @@ public final class VersonSet: Command { } public func run(arguments: [String]) throws { + let updateBar = console.loadingBar(title: "Updating Package Version") + updateBar.start() + let package = try value("name", from: arguments) let version = try value("version", from: arguments) let versionLitteral = versionOption(from: arguments, with: version) @@ -76,8 +82,22 @@ public final class VersonSet: Command { options: [] ) pattern.replaceMatches(in: manifest, options: [], range: NSMakeRange(0, manifest.length), withTemplate: "$1\(versionLitteral)$3") - try Manifest.current.write(String(manifest)) + + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "update"]) + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "resolve"]) + + updateBar.finish() + + if let _ = arguments.options["xcode"] { + let xcodeBar = console.loadingBar(title: "Generating Xcode Project") + xcodeBar.start() + _ = try console.backgroundExecute(program: "swift", arguments: ["package", "generate-xcodeproj"]) + xcodeBar.finish() + try console.execute(program: "/bin/sh", arguments: ["-c", "open *.xcodeproj"], input: nil, output: nil, error: nil) + } + + console.output("\(package) version was updated", style: .plain, newLine: true) } private func versionOption(from arguments: [String], with version: String) -> String { From e9190fbdafd6b6307a25d4c0ad827bb8533c1936 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Fri, 16 Feb 2018 17:21:37 -0600 Subject: [PATCH 15/19] Updated VersionLatest comand regex to find packages with any version type --- Sources/Ether/VersionLatest.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Ether/VersionLatest.swift b/Sources/Ether/VersionLatest.swift index f0e4fb4..47342c5 100644 --- a/Sources/Ether/VersionLatest.swift +++ b/Sources/Ether/VersionLatest.swift @@ -55,7 +55,7 @@ public final class VersionLatest: Command { let fileManager = FileManager.default let manifest = try Manifest.current.get() let nsManifest = NSMutableString(string: manifest) - let versionPattern = try NSRegularExpression(pattern: "(.package\\(url:\\s*\".*?\\.com\\/(.*?)\\.git\",\\s*)(\\.?\\w+(\\(|:)\\s*\"[\\w\\.]+\"\\)?)(\\))", options: []) + let versionPattern = try NSRegularExpression(pattern: "(.package\\(url:\\s*\".*?\\.com\\/(.*?)\\.git\",\\s*)(.*?)(\\),?\\n)", options: []) let matches = versionPattern.matches(in: manifest, options: [], range: NSMakeRange(0, manifest.utf8.count)) let packageNames = matches.map { match -> String in let name = versionPattern.replacementString(for: match, in: manifest, offset: 0, template: "$2") From d30bf44d853622c4cf7d414eb1719d0c790ebd36 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Fri, 16 Feb 2018 17:24:16 -0600 Subject: [PATCH 16/19] Updated VersionAll command script to use Manifest API --- Sources/Ether/VersionAll.swift | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/Sources/Ether/VersionAll.swift b/Sources/Ether/VersionAll.swift index a923dec..880a913 100644 --- a/Sources/Ether/VersionAll.swift +++ b/Sources/Ether/VersionAll.swift @@ -43,23 +43,12 @@ public final class VersionAll: Command { let fetchingDataBar = console.loadingBar(title: "Getting Package Data") fetchingDataBar.start() - let manager = FileManager.default - - guard let packageData = manager.contents(atPath: "\(manager.currentDirectoryPath)/Package.resolved") else { - throw fail(bar: fetchingDataBar, with: "Make sure you are in the root of an SPM project.") - } - - guard let packageJson = try packageData.json()?["object"] as? [String: AnyObject] else { - throw fail(bar: fetchingDataBar, with: "Unable to parse data from Package.resolved.") - } - - if let pins = packageJson["pins"] as? [[String: AnyObject]] { - fetchingDataBar.finish() - pins.forEach { package in - console.output("\(package["package"] ?? "N/A" as AnyObject): ", style: .success, newLine: false) - if let state = package["state"] as? [String: AnyObject] { - console.output("v\(state["version"] ?? "N/A" as AnyObject)", style: .plain, newLine: true) - } + let pins = try Manifest.current.getPins() + fetchingDataBar.finish() + pins.forEach { package in + console.output("\(package["package"] ?? "N/A" as AnyObject): ", style: .success, newLine: false) + if let state = package["state"] as? [String: AnyObject] { + console.output("v\(state["version"] ?? "N/A" as AnyObject)", style: .plain, newLine: true) } } } From 98d1aa018523c422ee55fe4b1f0bca2b7a4258d7 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Fri, 16 Feb 2018 17:28:15 -0600 Subject: [PATCH 17/19] Updated Remove command regex to handle packages with any version type --- Sources/Ether/Remove.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Ether/Remove.swift b/Sources/Ether/Remove.swift index c127b2c..c4eaa33 100644 --- a/Sources/Ether/Remove.swift +++ b/Sources/Ether/Remove.swift @@ -54,7 +54,7 @@ public final class Remove: Command { let name = try value("name", from: arguments) let url = try Manifest.current.getPackageUrl(for: name) - let regex = try NSRegularExpression(pattern: "\\,?\\n *\\.package\\(url: *\"\(url)\", *\\.?\\w+(:|\\() *\"([\\d\\.]+)\"\\)?\\),?", options: .caseInsensitive) + let regex = try NSRegularExpression(pattern: "(\\,?\\n *\\.package\\(url: *\"\(url)\", *)(.*?)(?=,?\n)", options: .caseInsensitive) let oldPins = try Manifest.current.getPins() let packageString = try Manifest.current.get() From 5bd0e595e6ddddf5712aabc01f0d0682be12d282 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Fri, 16 Feb 2018 17:32:14 -0600 Subject: [PATCH 18/19] Added v1.10.0 entry to CHANGELOG --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c75ccac..9fe1b7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [1.10.0] 2018-02-18 + +### Added +- `ether version set` command to update the version of a single package. + +### Updated +- The RegEx for any command that matches the version of a package, so it handles any version type for a package. + ## [1.9.2] 2017-11-27 ### Fixed From 05a23fa56101b5dfda915fb364e307faeffccd15 Mon Sep 17 00:00:00 2001 From: Caleb Kleveter Date: Fri, 16 Feb 2018 17:32:40 -0600 Subject: [PATCH 19/19] Updated executable version --- Sources/Executable/main.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Executable/main.swift b/Sources/Executable/main.swift index 001bf53..172104e 100644 --- a/Sources/Executable/main.swift +++ b/Sources/Executable/main.swift @@ -27,7 +27,7 @@ import Helpers import libc // The current version of Ether. This string should be updated with each release. -let version = "1.9.2" +let version = "1.10.0" var arguments = CommandLine.arguments let terminal = Terminal(arguments: arguments) var iterator = arguments.makeIterator()