forked from rmosolgo/graphql-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
96 lines (82 loc) · 2.74 KB
/
Rakefile
File metadata and controls
96 lines (82 loc) · 2.74 KB
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
# frozen_string_literal: true
require "bundler/setup"
Bundler::GemHelper.install_tasks
require "rake/testtask"
Rake::TestTask.new do |t|
t.libs << "spec" << "lib"
t.pattern = "spec/**/*_spec.rb"
t.warning = false
end
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop) do |t|
t.patterns = Rake::FileList['lib/**/{*}.rb', 'spec/**/*.rb']
.exclude("lib/graphql/language/parser.rb")
.exclude("lib/graphql/language/lexer.rb")
end
task(default: [:test, :rubocop])
desc "Use Racc & Ragel to regenerate parser.rb & lexer.rb from configuration files"
task :build_parser do
`rm -f lib/graphql/language/parser.rb lib/graphql/language/lexer.rb `
`racc lib/graphql/language/parser.y -o lib/graphql/language/parser.rb`
`ragel -R lib/graphql/language/lexer.rl`
end
namespace :site do
desc "View the documentation site locally"
task :serve do
require "jekyll"
options = {
"source" => File.expand_path("guides"),
"destination" => File.expand_path("guides/_site"),
"watch" => true,
"serving" => true
}
# Generate the site in server mode.
puts "Running Jekyll..."
Jekyll::Commands::Build.process(options)
Jekyll::Commands::Serve.process(options)
end
desc "Commit the local site to the gh-pages branch and publish to GitHub Pages"
task :publish do
# Ensure the gh-pages dir exists so we can generate into it.
puts "Checking for gh-pages dir..."
unless File.exist?("./gh-pages")
puts "Creating gh-pages dir..."
sh "git clone git@github.com:rmosolgo/graphql-ruby gh-pages"
end
# Ensure latest gh-pages branch history.
Dir.chdir("gh-pages") do
sh "git checkout gh-pages"
sh "git pull origin gh-pages"
end
# Proceed to purge all files in case we removed a file in this release.
puts "Cleaning gh-pages directory..."
purge_exclude = [
'gh-pages/.',
'gh-pages/..',
'gh-pages/.git',
'gh-pages/.gitignore',
]
FileList["gh-pages/{*,.*}"].exclude(*purge_exclude).each do |path|
sh "rm -rf #{path}"
end
# Copy site to gh-pages dir.
puts "Building site into gh-pages branch..."
ENV['JEKYLL_ENV'] = 'production'
require "jekyll"
Jekyll::Commands::Build.process({
"source" => File.expand_path("guides"),
"destination" => File.expand_path("gh-pages"),
"sass" => { "style" => "compressed" }
})
File.open('gh-pages/.nojekyll', 'wb') { |f| f.puts(":dog: food.") }
# Commit and push.
puts "Committing and pushing to GitHub Pages..."
sha = `git rev-parse HEAD`.strip
Dir.chdir('gh-pages') do
sh "git add ."
sh "git commit --allow-empty -m 'Updating to #{sha}.'"
sh "git push origin gh-pages"
end
puts 'Done.'
end
end