Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,28 @@ let package = Package(
targets: ["YCatalogViewer"]
)
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.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.
.binaryTarget(
name: "SwiftLintBinary",
url: "https://github.com/realm/SwiftLint/releases/download/0.47.1/SwiftLintBinary-macos.artifactbundle.zip",
checksum: "82ef90b7d76b02e41edd73423687d9cedf0bb9849dcbedad8df3a461e5a7b555"
),
.plugin(
name: "SwiftLint",
capability: .buildTool(),
dependencies: ["SwiftLintBinary"]
),
.target(
name: "YCatalogViewer",
dependencies: []
dependencies: [],
plugins: ["SwiftLint"]
),
.testTarget(
name: "YCatalogViewerTests",
dependencies: ["YCatalogViewer"]
dependencies: ["YCatalogViewer"],
plugins: ["SwiftLint"]
)
]
)
30 changes: 30 additions & 0 deletions Plugins/SwiftLint/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// main.swift
// YCatalogViewer
//
// Created by Tim Barett on 7/20/22.
// Copyright © 2021 Y Media Labs. All rights reserved.
//

import PackagePlugin

@main
struct SwiftLint: BuildToolPlugin {
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
[
.buildCommand(
displayName: "Linting \(target.name)...",
executable: try context.tool(named: "swiftlint").path,
arguments: [
"lint",
"--in-process-sourcekit",
"--config",
"\(context.package.directory.string)/.swiftlint.yml",
"--path",
target.directory.string
],
environment: [:]
)
]
}
}