1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require "pathname"
$LOAD_PATH.unshift(Pathname.new(__dir__) / "lib")
require "minitest/test_task"
Minitest::TestTask.create
Dir.glob("tasks/*.rake").sort.each do
import it
end
desc "Start development server, reloading on changes"
task :dev do
sh "fd -e rb . lib | entr -r rackup -o localhost"
end
desc "Regenerate macOS exchange response fixtures from current responses"
task :fixtures do
# Mirrors test/test_helper.rb, which cannot be required here without
# minitest/autorun running its at_exit hook inside rake.
ENV["PRO_TACTS_DATA_DIR"] = (Pathname.new(__dir__) / "test/fixtures").to_s
require "pro_tacts/web"
require_relative "test/pro_tacts/exchange_fixtures"
ExchangeFixtures.record_responses(ProTacts::Web)
end
desc "Type check lib against the RBS comments in it"
task :steep do
sh "steep", "check"
end
desc "Render the macOS configuration profile (carddav.mobileconfig)"
task profile: "carddav.mobileconfig"
# Rebuilds when the template changes but not when PRO_TACTS_HOSTNAME does;
# delete carddav.mobileconfig to force a rerender.
file "carddav.mobileconfig" => "lib/pro_tacts/profile.rb" do |task|
require "pro_tacts/profile"
File.write(task.name, ProTacts::Profile.render(
hostname: ENV.fetch("PRO_TACTS_HOSTNAME")
))
end
namespace :profile do
desc "Remove installed pro-tacts profiles, then stage a fresh one for approval"
task install: :remove do
require "pro_tacts/profile"
File.write("carddav.mobileconfig", ProTacts::Profile.render(
hostname: ENV.fetch("PRO_TACTS_HOSTNAME")
))
sh "open", "carddav.mobileconfig"
sh "open", "x-apple.systempreferences:com.apple.preferences.configurationprofiles"
end
desc "Remove every installed pro-tacts configuration profile"
task :remove do
require "pro_tacts/profile"
identifiers = ProTacts::Profile.installed_identifiers(`profiles list`)
if identifiers.empty?
puts "No pro-tacts profiles found; remove by hand in System Settings → Profiles if one lingers."
else
identifiers.each do
sh "profiles", "remove", "-identifier", it
end
end
end
end
task default: %i[ steep test ]