mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 03:23:08 +00:00
📦 Declare mas as a Swift Package
This commit is contained in:
parent
d287c5cfd6
commit
7a7f36ad9b
15 changed files with 159 additions and 6 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -22,9 +22,11 @@
|
|||
.VolumeIcon.icns
|
||||
._*
|
||||
.apdisk
|
||||
.build/
|
||||
.envrc
|
||||
.fseventsd
|
||||
.rubygems/
|
||||
.swiftpm/
|
||||
Carthage/
|
||||
DerivedData
|
||||
Pods/
|
||||
|
|
61
Package.resolved
Normal file
61
Package.resolved
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"object": {
|
||||
"pins": [
|
||||
{
|
||||
"package": "Commandant",
|
||||
"repositoryURL": "https://github.com/Carthage/Commandant.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "a1671cf728db837cf5ec1980a80d276bbba748f6",
|
||||
"version": "0.18.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "CwlCatchException",
|
||||
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "f809deb30dc5c9d9b78c872e553261a61177721a",
|
||||
"version": "2.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "CwlPreconditionTesting",
|
||||
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "02b7a39a99c4da27abe03cab2053a9034379639f",
|
||||
"version": "2.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Nimble",
|
||||
"repositoryURL": "https://github.com/Quick/Nimble.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "7a54aaf19a8ef16f67787c260fda81ead7ba4d67",
|
||||
"version": "9.0.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Quick",
|
||||
"repositoryURL": "https://github.com/Quick/Quick.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "8cce6acd38f965f5baa3167b939f86500314022b",
|
||||
"version": "3.1.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Version",
|
||||
"repositoryURL": "https://github.com/mxcl/Version.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "a94b48f36763c05629fc102837398505032dead9",
|
||||
"version": "2.0.0"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"version": 1
|
||||
}
|
73
Package.swift
Normal file
73
Package.swift
Normal file
|
@ -0,0 +1,73 @@
|
|||
// swift-tools-version:5.3
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "mas",
|
||||
platforms: [
|
||||
.macOS(.v10_11),
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.executable(
|
||||
name: "mas",
|
||||
targets: ["mas"]
|
||||
),
|
||||
.library(
|
||||
name: "MasKit",
|
||||
targets: ["MasKit"]
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
.package(url: "https://github.com/Carthage/Commandant.git", from: "0.18.0"),
|
||||
.package(url: "https://github.com/Quick/Nimble.git", from: "9.0.1"),
|
||||
.package(url: "https://github.com/Quick/Quick.git", from: "3.1.2"),
|
||||
.package(url: "https://github.com/mxcl/Version.git", from: "2.0.0"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||
.target(
|
||||
name: "mas",
|
||||
dependencies: ["MasKit"],
|
||||
swiftSettings: [
|
||||
.unsafeFlags([
|
||||
"-F", "/System/Library/PrivateFrameworks",
|
||||
"-I", "Sources/PrivateFrameworks/CommerceKit",
|
||||
"-I", "Sources/PrivateFrameworks/StoreFoundation",
|
||||
]),
|
||||
]
|
||||
),
|
||||
.target(
|
||||
name: "MasKit",
|
||||
dependencies: ["Commandant", "Version"],
|
||||
swiftSettings: [
|
||||
.unsafeFlags([
|
||||
"-F", "/System/Library/PrivateFrameworks",
|
||||
"-I", "Sources/PrivateFrameworks/CommerceKit",
|
||||
"-I", "Sources/PrivateFrameworks/StoreFoundation",
|
||||
]),
|
||||
],
|
||||
linkerSettings: [
|
||||
.linkedFramework("CommerceKit"),
|
||||
.linkedFramework("StoreFoundation"),
|
||||
.unsafeFlags(["-F", "/System/Library/PrivateFrameworks"]),
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
name: "MasKitTests",
|
||||
dependencies: ["MasKit", "Nimble", "Quick"],
|
||||
resources: [.copy("JSON")],
|
||||
swiftSettings: [
|
||||
.unsafeFlags([
|
||||
"-F", "/System/Library/PrivateFrameworks",
|
||||
"-I", "Sources/PrivateFrameworks/CommerceKit",
|
||||
"-I", "Sources/PrivateFrameworks/StoreFoundation",
|
||||
]),
|
||||
]
|
||||
),
|
||||
],
|
||||
swiftLanguageVersions: [.v5]
|
||||
)
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Foundation
|
||||
|
||||
private let markerValue = "appstore"
|
||||
private let masScheme = "macappstore"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Foundation
|
||||
|
||||
/// Command which displays a list of installed apps which have available updates
|
||||
/// ready to be installed from the Mac App Store.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Foundation
|
||||
|
||||
/// Command which upgrades apps with new versions available in the Mac App Store.
|
||||
public struct UpgradeCommand: CommandProtocol {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
import Commandant
|
||||
import Foundation
|
||||
|
||||
/// Command which displays the version of the mas tool.
|
||||
public struct VersionCommand: CommandProtocol {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright © 2019 mas-cli. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Nimble
|
||||
import Quick
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright © 2018 mas-cli. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Nimble
|
||||
import Quick
|
||||
|
||||
|
|
|
@ -24,7 +24,13 @@ extension Bundle {
|
|||
/// - Parameter fileName: Name of file to locate.
|
||||
/// - Returns: URL to file.
|
||||
static func url(for fileName: String) -> URL? {
|
||||
Bundle(for: NetworkSessionMock.self).url(for: fileName)
|
||||
var bundle = Bundle(for: NetworkSessionMock.self)
|
||||
#if SWIFT_PACKAGE
|
||||
// The Swift Package Manager places resources in a separate bundle from the executable.
|
||||
bundle =
|
||||
Bundle(url: bundle.bundleURL.deletingLastPathComponent().appendingPathComponent("mas_MasKitTests.bundle"))!
|
||||
#endif
|
||||
return bundle.url(for: fileName)
|
||||
}
|
||||
|
||||
/// Builds a URL for a file in the JSON directory of the current bundle.
|
||||
|
@ -33,13 +39,13 @@ extension Bundle {
|
|||
/// - Returns: URL to file.
|
||||
func url(for fileName: String) -> URL? {
|
||||
guard
|
||||
let path = self.path(
|
||||
let url = self.url(
|
||||
forResource: fileName.fileNameWithoutExtension,
|
||||
ofType: fileName.fileExtension,
|
||||
inDirectory: "JSON"
|
||||
withExtension: fileName.fileExtension,
|
||||
subdirectory: "JSON"
|
||||
)
|
||||
else { fatalError("Unable to load file \(fileName)") }
|
||||
|
||||
return URL(fileURLWithPath: path)
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright © 2020 mas-cli. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Nimble
|
||||
import Quick
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright © 2020 mas-cli. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Nimble
|
||||
import Quick
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@testable import MasKit
|
||||
|
||||
/// Mock NetworkSession for testing.
|
||||
|
|
|
@ -234,6 +234,7 @@
|
|||
B5DBF81221DEEC7C00F3B151 /* OpenCommandSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpenCommandSpec.swift; sourceTree = "<group>"; };
|
||||
B5DBF81421E02BA900F3B151 /* StoreSearchMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreSearchMock.swift; sourceTree = "<group>"; };
|
||||
B5DBF81621E02E3400F3B151 /* OpenSystemCommandMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenSystemCommandMock.swift; sourceTree = "<group>"; };
|
||||
C56F16DF2637825300EAC548 /* Package.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
|
||||
ED031A781B5127C00097692E /* mas */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mas; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
ED031A7B1B5127C00097692E /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
|
||||
ED0F237E1B87522400AE40CD /* Install.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Install.swift; sourceTree = "<group>"; };
|
||||
|
@ -543,6 +544,7 @@
|
|||
C56F16DB2637711100EAC548 /* Sources */,
|
||||
C56F16DC2637711900EAC548 /* Tests */,
|
||||
ED031A791B5127C00097692E /* Products */,
|
||||
C56F16DF2637825300EAC548 /* Package.swift */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ git diff --check
|
|||
|
||||
echo
|
||||
echo "--> 🕊️ Swift"
|
||||
for SOURCE in Sources Tests; do
|
||||
for SOURCE in Package.swift Sources Tests; do
|
||||
swiftformat --lint ${SOURCE}
|
||||
swift-format lint --configuration .swift-format --recursive ${SOURCE}
|
||||
swiftlint lint --strict ${SOURCE}
|
||||
|
|
Loading…
Reference in a new issue