Hey there everyone, I'm building a medium sized developer tool using SwiftPM (danger-swift) and am starting to collect a lot of single line commands for my project. These range from using my dependencies:
swift run sourcedocs generate --spm-module Danger --output-folder docs/reference
to building and installing the tool
swift build --disable-sandbox -c release --static-swift-stdlib
and then some useful snippets during deployment
get_sha:
wget https://github.com/danger/$(TOOL_NAME)/archive/$(VERSION).tar.gz -O $(TAR_FILENAME)
shasum -a 256 $(TAR_FILENAME)
rm $(TAR_FILENAME)
these all live in a Makefile today, but I spend most of my day inside node and really miss the "scripts" section of the package.json
. This is basically a section of composable smaller scripts (and hook-in points for custom commands during the dependency management) which lets you consolidate your CLI commands into a single place.
I was wondering if folks were interested in something like this:
let package = Package(
name: "danger-swift",
products: [
.library(name: "Danger", type: .dynamic, targets: ["Danger"]),
.executable(name: "danger-swift", targets: ["Runner"])
],
dependencies: [
.package(url: "https://github.com/JohnSundell/Marathon.git", from: "3.1.0"),
// Dev dependencies
.package(url: "https://github.com/eneko/SourceDocs.git", from: "0.5.1"),
.package(url: "https://github.com/realm/SwiftLint.git", from: "0.28.1"),
.package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.35.7"),
],
scripts: [
.command(name:"docs", "sourcedocs generate --spm-module Danger --output-folder Documentation/reference"),
.command(name: "format", "swiftformat"),
.command(name: "lint", "swiftlint"),
.command(name: "ci", ["lint", "format"]),
.command(name: "deploy", "node --require ts-node/register scripts/deploy.ts")
]
})
Which would allow:
// (already exists)
// compile the app, and run it
swift run danger-swift
// compile swiftlint, and run it
swift run swiftlint
// (new)
// effectively running "swift run swiftlint"
swift run lint
// runs both swift run lint, and then swift run format
swift run ci
// runs "swift run sourcedocs generate --spm-module Danger --output-folder docs/reference"
swift run docs
// Runs the command
swift run deploy
Are folks interested?