Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 1, 2017. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathRakefile
More file actions
Latest commit
111 lines (96 loc) · 3.3 KB
/
Copy pathRakefile
File metadata and controls
111 lines (96 loc) · 3.3 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
require_relative'lib/resources'
require'tmpdir'
Dir.glob('tasks/**/*.rake').each{ |r| loadr}
task:default=>[:test]
desc'Builds the site'
task:builddo
ifENV['RACK_ENV'] == 'test'
begin
sh'node_modules/gulp/bin/gulp.js build > build.txt'
rescueStandardError=>e
puts'uh oh'
$stderr.puts`cat build.txt`
raisee
end
else
sh'node_modules/gulp/bin/gulp.js build'
end
end
desc"Test the output"
task:test=>[:remove_tmp_dir,:remove_output_dir,:build]do
Rake::Task['spec'].invoke
Rake::Task['run_proofer'].invoke
end
desc"Run Rspec"
task:specdo
require'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:rspec)
Rake::Task['rspec'].invoke
end
desc"Run the HTML-Proofer"
task:run_prooferdo
require'html-proofer'
ignored_links=[%r{www.w3.org},/api\.github\.com/,/import\.github\.com/]
# swap versionless Enterprise articles with versioned paths
url_swap={
%r{help.github.com/enterprise/admin/}=>"help.github.com/enterprise/#{config[:versions][0]}/admin/",
%r{help.github.com/enterprise/user/}=>"help.github.com/enterprise/#{config[:versions][0]}/user/"
}
proofer_opts={
:url_ignore=>ignored_links,
:url_swap=>url_swap,
:parallel=>{:in_processes=>5}
}
HTMLProofer.check_directory("./output",proofer_opts).run
end
desc"Remove the tmp dir"
task:remove_tmp_dirdo
FileUtils.rm_r('tmp')ifFile.exist?('tmp')
end
desc"Remove the output dir"
task:remove_output_dirdo
FileUtils.rm_r('output')ifFile.exist?('output')
end
# Prompt user for a commit message; default: P U B L I S H :emoji:
defcommit_message(no_commit_msg=false)
publish_emojis=[':boom:',':rocket:',':metal:',':bulb:',':zap:',
':sailboat:',':gift:',':ship:',':shipit:',':sparkles:',':rainbow:']
default_message="P U B L I S H #{publish_emojis.sample}"
unlessno_commit_msg
print"Enter a commit message (default: '#{default_message}'): "
STDOUT.flush
mesg=STDIN.gets.chomp.strip
end
mesg=default_messageifmesg.nil? || mesg == ''
mesg << "\nGenerated from #{ENV['BUILD_SHA']}"ifENV['BUILD_SHA']
mesg.gsub(/'/,'')# Allow this to be handed off via -m '#{message}'
end
namespace:assetsdo
task:precompile=>[:build]do
sh'mv output _site/'
end
end
desc"Publish to http://developer.github.com"
task:publish,[:no_commit_msg]=>[:remove_tmp_dir,:remove_output_dir,:build]do |t,args|
message=commit_message(args[:no_commit_msg])
Dir.mktmpdirdo |tmp|
system"mv output/* #{tmp}"
system"cp .gitignore #{tmp}"
system'git checkout gh-pages'
system"rsync -av #{tmp}/ ."
system'git add .'
system"git commit -am #{message.shellescape}"
system'git push origin gh-pages --force'
system'git checkout master'
end
end
desc"Generate JSON from the sample responses"
task:generate_json_from_responsesdo
Dir[File.join(File.dirname(__FILE__),'lib','responses','*.rb')].each{ |file| loadfile}
FileUtils.mkdir_p(File.join(File.dirname(__FILE__),'json-dump'))
GitHub::Resources::Responses.constants.each{ |constant|
File.open('json-dump/' + constant.to_s + '.json','w'){ |file|
file.write(JSON.pretty_generate(GitHub::Resources::Helpers.get_resource(constant)))
}
}
end