forked from sketchplugins/plugin-directory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
62 lines (49 loc) · 1.6 KB
/
Rakefile
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
require 'json'
plugins = JSON.parse(IO.read('plugins.json'))
desc "Clones all repositories to the 'clones' folder"
task :clone do
mkdir "clones"
plugins.each do |plugin|
name = plugin['name']
owner = plugin['owner']
url = "https://github.com/#{owner}/#{name}"
system("git clone #{url} clones/#{owner}-#{name}")
end
end
desc "Updates all clones in the 'clones' folder"
task :update do
plugins.each do |plugin|
name = plugin['name']
owner = plugin['owner']
url = "https://github.com/#{owner}/#{name}"
if File.directory? "clones/#{owner}-#{name}"
puts "Updating #{owner}-#{name} to latest version"
system("cd clones/#{owner}-#{name}/ && git up")
else
puts "Cloning #{owner}-#{name} to latest version"
system("git clone #{url} clones/#{owner}-#{name}")
end
end
end
desc "Generate README.md from plugins.json"
task :readme do
output = <<EOF
# Sketch Plugin Directory
A list of Sketch plugins hosted at GitHub, in alphabetical order.
**Note:** if you want to add yours, just open an issue with the URL, or send a pull request.
EOF
plugins.sort_by { |k, v| k["owner"].downcase + "/" + k["name"].downcase }.each do |plugin|
name = plugin['name']
owner = plugin['owner']
url = "https://github.com/#{owner.downcase}/#{name.downcase}"
desc = plugin['description']
output << "- [#{owner}/#{name}](#{url}) #{desc}\n"
end
IO.write('README.md',output)
end
desc "List authors"
task :authors do
puts plugins.collect { |plugin| plugin['owner'] }.uniq.sort
end
desc "Default: generate README.md from plugin"
task :default => :readme