2018-04-01 16:47:30 +05:30
|
|
|
require "tap"
|
|
|
|
require "cli_parser"
|
|
|
|
|
2016-10-13 13:41:53 +01:00
|
|
|
module Homebrew
|
|
|
|
module_function
|
|
|
|
|
2018-07-30 18:25:38 +05:30
|
|
|
def tap_new_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
2018-09-28 21:39:52 +05:30
|
|
|
usage_banner <<~EOS
|
2018-10-15 15:06:33 -04:00
|
|
|
`tap-new` <user>`/`<repo>
|
2018-10-02 19:54:22 +05:30
|
|
|
|
2018-09-28 21:39:52 +05:30
|
|
|
Generate the template files for a new tap.
|
|
|
|
EOS
|
2018-04-01 16:47:30 +05:30
|
|
|
switch :verbose
|
2018-10-08 22:49:03 -04:00
|
|
|
switch :debug
|
2018-04-01 16:47:30 +05:30
|
|
|
end
|
2018-07-30 18:25:38 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def tap_new
|
|
|
|
tap_new_args.parse
|
2018-04-01 16:47:30 +05:30
|
|
|
|
2016-10-13 13:41:53 +01:00
|
|
|
raise "A tap argument is required" if ARGV.named.empty?
|
|
|
|
|
|
|
|
tap = Tap.fetch(ARGV.named.first)
|
|
|
|
titleized_user = tap.user.dup
|
|
|
|
titleized_repo = tap.repo.dup
|
|
|
|
titleized_user[0] = titleized_user[0].upcase
|
|
|
|
titleized_repo[0] = titleized_repo[0].upcase
|
|
|
|
|
|
|
|
(tap.path/"Formula").mkpath
|
|
|
|
|
2018-07-11 15:17:40 +02:00
|
|
|
readme = <<~MARKDOWN
|
2016-10-13 13:41:53 +01:00
|
|
|
# #{titleized_user} #{titleized_repo}
|
|
|
|
|
|
|
|
## How do I install these formulae?
|
|
|
|
`brew install #{tap}/<formula>`
|
|
|
|
|
|
|
|
Or `brew tap #{tap}` and then `brew install <formula>`.
|
|
|
|
|
|
|
|
Or install via URL (which will not receive updates):
|
|
|
|
|
|
|
|
```
|
|
|
|
brew install https://raw.githubusercontent.com/#{tap.user}/homebrew-#{tap.repo}/master/Formula/<formula>.rb
|
|
|
|
```
|
|
|
|
|
|
|
|
## Documentation
|
2017-07-27 15:59:37 +01:00
|
|
|
`brew help`, `man brew` or check [Homebrew's documentation](https://docs.brew.sh).
|
2018-07-11 15:17:40 +02:00
|
|
|
MARKDOWN
|
2016-10-13 13:41:53 +01:00
|
|
|
write_path(tap, "README.md", readme)
|
|
|
|
|
2018-12-30 21:13:24 +00:00
|
|
|
azure = <<~YAML
|
|
|
|
jobs:
|
|
|
|
- job: macOS
|
|
|
|
pool:
|
2019-01-24 20:36:03 +00:00
|
|
|
vmImage: macOS-10.13
|
2018-12-30 21:13:24 +00:00
|
|
|
steps:
|
|
|
|
- bash: |
|
2019-01-24 20:36:03 +00:00
|
|
|
set -e
|
|
|
|
sudo xcode-select --switch /Applications/Xcode_10.1.app/Contents/Developer
|
2018-12-30 21:13:24 +00:00
|
|
|
brew update
|
2019-03-14 23:51:09 +11:00
|
|
|
HOMEBREW_TAP_DIR="/usr/local/Homebrew/Library/Taps/#{tap.full_name}"
|
2018-12-30 21:13:24 +00:00
|
|
|
mkdir -p "$HOMEBREW_TAP_DIR"
|
|
|
|
rm -rf "$HOMEBREW_TAP_DIR"
|
|
|
|
ln -s "$PWD" "$HOMEBREW_TAP_DIR"
|
|
|
|
brew test-bot
|
|
|
|
displayName: Run brew test-bot
|
2018-07-11 15:17:40 +02:00
|
|
|
YAML
|
2018-12-30 21:13:24 +00:00
|
|
|
write_path(tap, "azure-pipelines.yml", azure)
|
2016-10-13 13:41:53 +01:00
|
|
|
end
|
2018-10-08 22:49:03 -04:00
|
|
|
|
|
|
|
def write_path(tap, filename, content)
|
|
|
|
path = tap.path/filename
|
|
|
|
tap.path.mkpath
|
|
|
|
raise "#{path} already exists" if path.exist?
|
|
|
|
|
|
|
|
path.write content
|
|
|
|
end
|
2016-10-13 13:41:53 +01:00
|
|
|
end
|