Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
130 lines (101 sloc) 3.12 KB
# Deploy with new API:
# - rake preview
# - visit http://0.0.0.0:4567 and verify everything was generated correctly
# - ensure data/api.yml has the correct sha/tag, if not just simply update it and use middleman to re-preview
# Deploy without updating the API:
# - middleman
# - visit http://0.0.0.0:4567 and verify everything was generated correctly
# - rake deploy
require "bundler/setup"
require 'yaml'
def git_initialize(repository)
unless File.exist?(".git")
system "git init"
system "git remote add origin https://github.com/emberjs/#{repository}.git"
end
end
def git_update
system "git fetch origin"
system "git reset --hard origin/master"
# Remove all files so we don't accidentally keep old stuff
# These will be regenerated by the build process
system "rm `git ls-files`"
end
def ember_path
File.expand_path(ENV['EMBER_PATH'] || File.expand_path("../../ember.js", __FILE__))
end
def ember_data_path
File.expand_path(ENV['EMBER_DATA_PATH'] || File.expand_path("../../ember-data", __FILE__))
end
def generate_docs
projects = {
"Ember.js" => { out: "api.yml", path: ember_path },
"Ember Data" => { out: "data_api.yml", path: ember_data_path }
}
projects.each do |name, options|
path = options[:path]
print "Generating #{name} docs data from #{path}... "
sha = nil
Dir.chdir(path) do
# returns either `tag` or `tag-numcommits-gSHA`
describe = `git describe --tags --always`.strip
sha = describe =~ /-g(.+)/ ? $1 : describe
Dir.chdir("docs") do
system("npm install") unless File.exist?('node_modules')
# Unfortunately -q doesn't always work so we get output
system("./node_modules/.bin/yuidoc -p -q")
end
end
# JSON is valid YAML
data = YAML.load_file(File.join(path, "docs/build/data.json"))
data["project"]["sha"] = sha
File.open(File.expand_path("../data/#{options[:out]}", __FILE__), "w") do |f|
YAML.dump(data, f)
end
puts "Built #{name} with SHA #{sha}"
end
end
def build
system "middleman build"
end
desc "Generate API Docs"
task :generate_docs do
generate_docs
end
desc "Build the website"
task :build => :generate_docs do
build
end
desc "Preview"
task :preview do
require 'listen'
generate_docs
paths = Dir.glob(File.join(ember_path, "packages/*/lib")) +
Dir.glob(File.join(ember_data_path, "packages/*/lib"))
listener = Listen.to(*paths, :filter => /\.js$/)
listener.change { generate_docs }
listener.start(false)
system "middleman server"
end
desc "Deploy the website to github pages"
task :deploy do |t, args|
require "highline/import"
message = ask("Provide a deployment message: ") do |q|
q.validate = /\w/
q.responses[:not_valid] = "Can't be empty."
end
mkdir_p "build"
Dir.chdir "build" do
git_initialize("emberjs.github.com")
git_update
build
# This screws up the build and isn't necessary
# rm_r "source/examples"
File.open("CNAME", 'w') do |f|
f.write "emberjs.com"
end
system "git add -A"
system "git commit -m '#{message.gsub("'", "\\'")}'"
system "git push origin master" unless ENV['NODEPLOY']
end
end
Jump to Line
Something went wrong with that request. Please try again.