Swiftpack.co - Package - yonaskolb/Mint

Mint 🌱

SPM Platforms Git Version Build Status license

A package manager that installs and runs Swift command line tool packages.

$ mint run realm/SwiftLint@0.22.0 swiftlint

This would install and run SwiftLint version 0.22.0

Mint is designed to be used with Swift command line tools that build with the Swift Package Manager. It makes installing, running and distributing these tools much easier.

  • ✅ easily run a specific version of a package
  • link a package globally
  • ✅ builds are cached by version
  • ✅ use different versions of a package side by side
  • ✅ easily run the latest version of a package
  • ✅ distribute your own packages without recipes and formulas
  • ✅ specify a list of versioned packages in a Mintfile for easy use

Homebrew is a popular method of distributing Swift executables, but that requires creating a formula and then maintaining that formula. Running specific versions of homebrew installations can also be tricky as only one global version is installed at any one time. Mint installs your package via SPM and lets you run multiple versions of that package, which are installed and cached in a central place.

If your Swift executable package builds with SPM, then it can be run with Mint! See Support for details.

Why is it called Mint?

Swift Packager Manager Tools -> SPMT -> Spearmint -> Mint! 🌱😄

Mint: a place where something is produced or manufactured

Installing

Make sure Xcode 9.2 is installed first.

Homebrew

$ brew install mint

Make

$ git clone https://github.com/yonaskolb/Mint.git
$ cd Mint
$ make

Using Mint itself!

Install
$ git clone https://github.com/yonaskolb/Mint.git
$ cd Mint
$ swift run mint install yonaskolb/mint
Update
$ mint install yonaskolb/mint

Swift Package Manager

Use CLI

$ git clone https://github.com/yonaskolb/Mint.git
$ cd Mint
$ swift run mint

Use as dependency

Add the following to your Package.swift file's dependencies:

.package(url: "https://github.com/yonaskolb/Mint.git", from: "0.10.0"),

And then import wherever needed: import MintKit

Road to 1.0

Until 1.0 is reached, minor versions will be breaking.

Usage

Run mint help to see usage instructions.

  • install: Installs a package, so it can be run with run later, and also links that version globally
  • run: Runs a package. This will install it first if it isn't already installed, though won't link it globally. It's useful for running a certain version.
  • list: Lists all currently installed packages and versions.
  • uninstall: Uninstalls a package by name.
  • bootstrap: Installs all the packages in your Mintfile without linking them globally

Package reference

run and install commands require a package reference parameter. This can be a shorthand for a github repo (mint install realm/SwiftLint) or a fully qualified git path (mint install https://github.com/realm/SwiftLint.git). In the case of run you can also just pass the name of the repo if it is already installed (run swiftlint). This will do a lookup of all installed packages. An optional version can be specified by appending @version, otherwise the newest tag or master will be used. Note that if you don't specify a version, the current tags must be loaded remotely each time.

Examples

$ mint run yonaskolb/XcodeGen@1.2.4 xcodegen --spec spec.yml # pass some arguments
$ mint install yonaskolb/XcodeGen@1.2.4 --no-link # installs a certain version but doesn't link it globally
$ mint install yonaskolb/XcodeGen # install newest tag
$ mint install yonaskolb/XcodeGen@master --force #reinstall the master branch
$ mint run yonaskolb/XcodeGen@1.2.4 # run 1.2.4
$ mint run XcodeGen # use newest tag and find XcodeGen in installed packages

Linking

By default Mint symlinks your installs into usr/local/bin on mint install, unless --no-link is passed. This means a package will be accessible from anywhere, and you don't have to prepend commands with mint run package. Note that only one linked version can be used at a time though. If you need to run a specific older version use mint run.

Mintfile

A Mintfile can specify a list of versioned packages. It makes installing and running these packages easy, as the specific repos and versions are centralized.

Simply place this file in the directory you're running Mint in. The format of the Mintfile is simply a list of packages in the same form as the usual package parameter:

yonaskolb/xcodegen@1.10.3
yonaskolb/genesis@0.2.0

Then you can simply run a package with:

mint run xcodegen

Or install all the packages in one go with:

mint bootstrap

Advanced

  • You can use --silent in mint run to silence any output from mint itself. Useful if forwarding output somewhere else.
  • You can set MINT_PATH and MINT_LINK_PATH envs to configure where mint caches builds, and where it symlinks global installs. These default to /usr/local/lib/mint and /usr/local/bin respectively
  • You can use mint install --force to reinstall a package even if it's already installed. This shouldn't be required unless you are pointing at a branch and want to update it.

Linux

Mint works on Linux but has some limitations:

  • linux doesn't support building with a statically linked version of Swift. This means when a new version of swift comes out the old installs won't work on linux. A stable ABI in Swift 5 will remove the need for this.
  • Linux is case sensitive so you must specify the correct case for repo urls as well as executables.

Support

If your Swift command line tool builds with the Swift Package Manager than it will automatically install and run with mint! You can add this to the Installing section in your readme:

### [Mint](https://github.com/yonaskolb/mint)
```
$ mint install github_name/repo_name
```

Resources

The Swift Package Manager doesn't yet have a way of specifying resources directories. If your tool requires access to resources from the repo you require a custom Package.resources file. This is a plain text file that lists the resources directories on different lines:

MyFiles
MyOtherFiles

If this file is found in you repo, then all those directories will be copied into the same path as the executable.

A list of popular Mint compatible packages 🌱

Feel free to add your own!

Github

link
Stars: 656
Help us keep the lights on

Used By

Total:

Releases

0.11.2 - Aug 13, 2018

Added

  • Packages can now be referenced by name in mint install when already installed #100 @yonaskolb

Fixed

  • Fixed packages from Mintfile not being read correctly on mint run when specified by name #100 @yonaskolb

Commits

0.11.1 - Aug 9, 2018

Fixed

  • Fixed not being able to pass arguments to mint run @yonaskolb

Commits

0.11.0 - Aug 7, 2018

Added

  • Added Linux support #82 @yonaskolb
  • Executable names are now automatically read from Package.swift #95 @yonaskolb
  • All executables in Package.swift are now installed #95 @yonaskolb
  • If multiple executables exist and one is not provided in mint run it will ask you which one to run #95 @yonaskolb

Changed

  • Breaking: changed MINT_INSTALL_PATH env to MINT_LINK_PATH #97 @yonaskolb
  • Breaking: changed --prevent-global to --no-link #97 @yonaskolb
  • Breaking: replaced mint update with mint install --force #96 @yonaskolb
  • --silent now applies to mint install in addition to mint run @yonaskolb

Removed

  • Breaking: Swift packages without executable products are no longer supported
  • Breaking: Older style quoted command invocations are no longer supported. eg mint run realm/SwiftLint "swiftlint autocorrect"

Fixed

  • Fixed Mintfile output not adhering to --silent #85 @yutailang0119
  • Fixed installing nested resourcs in Package.resources #93 @toshi0383

Commits

0.10.2 - Jun 23, 2018

Fixed

  • Don't overwrite install path of already installed version until after successful build
  • Fixed version number output

Changed

  • Updated SwiftCLI 5.2.1 to allow nested help commands like mint help install

Commits

0.10.1 - Jun 7, 2018

Fixed

  • Fixed environment variables not being passed via mint run @yonaskolb
  • Fixed mint bootstrap output referring to the wrong path for Mintfile @yonaskolb

Commits