├── README.md └── mason.rb /README.md: -------------------------------------------------------------------------------- 1 | # Mason for Homebrew 2 | 3 | This is the official [mason][mason_link] tap for [homebrew][homebrew_link]. 4 | 5 | Mac users can use these formulas to easily install and update mason. 6 | 7 | ## Initial Setup 8 | 9 | If you don't have homebrew, install it from their [homepage][homebrew_link]. 10 | 11 | Then add this tap: 12 | 13 | ```sh 14 | brew tap felangel/mason 15 | ``` 16 | 17 | ## Installing 18 | 19 | To install mason: 20 | 21 | ```sh 22 | brew install mason 23 | ``` 24 | 25 | ## Updating 26 | 27 | To update `mason` run: 28 | 29 | ```sh 30 | brew update 31 | brew upgrade mason 32 | ``` 33 | 34 | ## Uninstalling 35 | 36 | To uninstall `mason` run: 37 | 38 | ```sh 39 | brew uninstall mason 40 | brew untap felangel/mason 41 | ``` 42 | 43 | [homebrew_link]: https://brew.sh/ 44 | [mason_link]: https://github.com/felangel/mason 45 | -------------------------------------------------------------------------------- /mason.rb: -------------------------------------------------------------------------------- 1 | require "yaml" 2 | 3 | class Mason < Formula 4 | desc "A template generator which helps teams generate files quickly and consistently." 5 | homepage "https://github.com/felangel/mason" 6 | url "https://github.com/felangel/mason/archive/refs/tags/mason_cli-v0.1.3.tar.gz" 7 | sha256 "a21a2de3bb340d9811d5fe32608a031a65dcd0499b4b9688784a275a48d471ba" 8 | license "MIT" 9 | 10 | depends_on "dart-lang/dart/dart" => :build 11 | 12 | def install 13 | # Tell the pub server where these installations are coming from. 14 | ENV["PUB_ENVIRONMENT"] = "homebrew:mason_cli" 15 | 16 | # Change directories into the mason_cli package directory. 17 | Dir.chdir('packages/mason_cli') 18 | 19 | system _dart/"dart", "pub", "get" 20 | 21 | _install_script_snapshot 22 | 23 | chmod 0555, "#{bin}/mason" 24 | end 25 | 26 | private 27 | 28 | def _dart 29 | @_dart ||= Formula["dart-lang/dart/dart"].libexec/"bin" 30 | end 31 | 32 | def _version 33 | @_version ||= YAML.safe_load(File.read("pubspec.yaml"))["version"] 34 | end 35 | 36 | def _install_script_snapshot 37 | system _dart/"dart", "compile", "jit-snapshot", 38 | "-Dversion=#{_version}", 39 | "-o", "mason.dart.app.snapshot", 40 | "bin/mason.dart" 41 | lib.install "mason.dart.app.snapshot" 42 | 43 | cp _dart/"dart", lib 44 | 45 | (bin/"mason").write <<~SH 46 | #!/bin/sh 47 | exec "#{lib}/dart" "#{lib}/mason.dart.app.snapshot" "$@" 48 | SH 49 | end 50 | end 51 | --------------------------------------------------------------------------------