Skip to content

Commit b74fcdd

Browse files
committed
Fix merge conflicts
2 parents 729a407 + 4187435 commit b74fcdd

File tree

3,127 files changed

+19008
-6009
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,127 files changed

+19008
-6009
lines changed

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.3
1+
2.2.5

CONTRIBUTING.md

Lines changed: 313 additions & 58 deletions
Large diffs are not rendered by default.

Gemfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
source "https://rubygems.org"
2-
ruby "2.2.3"
2+
ruby "2.2.5"
33

4-
gem "sass", "~>3.4.18"
4+
gem "sass", "~>3.4.22"
55
gem "sass-css-importer", ">=1.0.0.beta.0"
66
gem "compass", "~>1.0.3"
7-
gem "sprockets", "~>3.5"
7+
gem "sprockets", "~>3.7"
88
gem "coffee-script", "~>2.4.1"
9-
gem "uglifier", "~>2.7.2"
9+
gem "uglifier", "~>3.0.0"
1010

11-
gem "aws-sdk", "~> 2.2.11"
11+
gem "aws-sdk", "~> 2.4.3"
1212
gem "aws-s3", "~> 0.6.3"
1313
gem "simple-cloudfront-invalidator", "~>1.1.0"
1414
gem "progressbar", "~> 0.21.0"
@@ -17,9 +17,9 @@ gem "progressbar", "~> 0.21.0"
1717
# gem "coderay", "~>"
1818
# gem "pygmentize", "~>"
1919

20-
gem "rake", "~>10.4.2"
21-
gem "guard", "~>2.13.0"
20+
gem "rake", "~>11.2.2"
21+
gem "guard", "~>2.14.0"
2222
gem "guard-rake", "~>1.0.0"
2323

2424
gem "pry", "~>0.10.3"
25-
gem "pry-byebug", "~>3.3.0"
25+
gem "pry-byebug", "~>3.4.0"

Rakefile

Lines changed: 73 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
#TODO<drew.pirrone.brusse@gmail>: Make sure the above description is correct and
1111
# complete.
1212

13-
require './libs/basho_rake_deploy'
14-
require './libs/basho_downloads_gen'
13+
require_relative 'rake_libs/compile_js'
14+
require_relative 'rake_libs/compile_css'
15+
require_relative 'rake_libs/s3_deploy'
16+
require_relative 'rake_libs/downloads_metadata_generator'
17+
require_relative 'rake_libs/projects_metadata_generator'
1518

1619
$css_source = "./dynamic/css"
1720
$css_dest = "./static/css"
@@ -31,9 +34,9 @@ directory "#{$cache_dir}"
3134
######################################################################
3235
### Rake Namespace and Task definitions
3336

34-
Rake::TaskManager.record_task_metadata = true
3537
##########
3638
# Default
39+
Rake::TaskManager.record_task_metadata = true
3740
task :default do
3841
puts("Basho Documentation Generate System Usage:")
3942
puts("")
@@ -45,78 +48,74 @@ end;
4548

4649
########
4750
# Clean
48-
desc "Clean previous builds"
51+
#TODO<drew.pirrone.brusse@gmail>: These `rm -rf`s are maybe a bit much? Should
52+
# we be more precise with what we delete (and, if so, how)?
53+
desc "Clean dynamically generated content (does not clean Hugo content)"
4954
task :clean => ['clean:js', 'clean:css']
5055
namespace :clean do
51-
#TODO<drew.pirrone.brusse@gmail>: These `rm -rf`s are maybe a bit much? Should
52-
# we be more precise with what we delete (and, if so, how)?
56+
desc "Clean dynamically generated JS"
5357
task :js do
54-
# Ignoring files from standalone/, as they're from the Middleman content
55-
js_file_list = Dir["#{$js_dest}/**/**"].reject { |f| f =~ /standalone/ }
58+
# The standalone/ directory may exist if we've extracted archived content
59+
# (see deploy:fetch_archived_content). We don't want to remove those files.
60+
js_file_list = Dir["#{$js_dest}/**/*"].reject {|f| /standalone/.match(f) }
5661
js_file_list.each do |f|
57-
log_dir_deletion(f)
62+
log_deletion(f)
5863
FileUtils.rm(f)
5964
end
6065
end
66+
desc "Clean dynamically generated CSS"
6167
task :css do
62-
# Ignoring files from standalone/, as they're from the Middleman content
63-
css_file_list = Dir["#{$css_dest}/**/**"].reject { |f| f =~ /standalone/ }
68+
# The standalone/ directory may exist if we've extracted archived content
69+
# (see deploy:fetch_archived_content). We don't want to remove those files.
70+
css_file_list = Dir["#{$css_dest}/**/*"].reject {|f| /standalone/.match(f) }
6471
css_file_list.each do |f|
65-
log_dir_deletion(f)
72+
log_deletion(f)
6673
FileUtils.rm(f)
6774
end
6875
end
76+
desc "Clean Hugo-generated content"
6977
task :hugo do
70-
log_dir_deletion($hugo_dest)
78+
log_deletion($hugo_dest)
7179
FileUtils.rm_rf($hugo_dest)
7280
end
7381
end
7482

7583

7684
########
7785
# Build
78-
desc "Compile Compressed JS, Compile Compressed CSS, Build Hugo"
86+
desc "Compile compressed JS and compressed CSS"
7987
task :build => ['clean', 'build:js', 'build:css']
8088
namespace :build do
81-
task :js => "#{$js_dest}" do compile_js(debug: false); end
82-
task :css => "#{$css_dest}" do compile_css(debug: false); end
83-
84-
desc "Build all statically-generated Hugo content"
85-
task :hugo => ['clean:hugo'] do sh "hugo -d #{$hugo_dest}"; end
86-
87-
desc "Shorthand for `rake build; rake watch:hugo` (Note: exits w/ an error)"
88-
task :watch => ['build:js', 'build:css', 'watch:hugo']
89+
task :js => ["#{$js_dest}", 'clean:js'] do compile_js(debug: false); end
90+
task :css => ["#{$css_dest}", 'clean:css'] do compile_css(debug: false); end
8991

9092
################
9193
# Build : Debug
92-
desc "Compile Human-Readable JS, Compile Human-Readable CSS, Build Hugo"
93-
task :debug => ['build:debug:js', 'build:debug:css', 'build:hugo']
94+
desc "Compile human-readable JS and compile human-readable CSS"
95+
task :debug => ["#{$js_dest}", "#{$css_dest}",
96+
'build:debug:js', 'build:debug:css']
9497
namespace :debug do
95-
desc "Compile Human-Readable JS"
96-
task :js => "#{$js_dest}" do compile_js(debug: true); end
98+
desc "Compile human-readable JS"
99+
task :js => ["#{$js_dest}"] do compile_js(debug: true); end
97100

98-
desc "Compile Human-Readable CSS"
99-
task :css => "#{$css_dest}" do compile_css(debug: true); end
101+
desc "Compile human-readable CSS"
102+
task :css => ["#{$css_dest}"] do compile_css(debug: true); end
100103
end
101104
end
102105

103106

104107
########
105108
# Watch
106-
desc "Run Guard on JS and CSS"
109+
desc "Rebuild compressed JS and CSS content on file saves"
107110
task :watch do sh 'bundle exec guard -g css js'; end
108111
namespace :watch do
109112

110113
task :js do sh 'bundle exec guard -g js'; end
111114
task :css do sh 'bundle exec guard -g css'; end
112115

113-
#TODO<drew.pirrone.brusse@gmail>: Add in some way to specify ip/port.
114-
desc "Run Hugo Server"
115-
task :hugo do sh "hugo server --ignoreCache=true"; end
116-
117116
################
118117
# Watch : Debug
119-
desc "Run Guard on JS and CSS in Debug Mode"
118+
desc "Rebuild human-readable JS and CSS content on file saves"
120119
task :debug => ['clean'] do sh 'bundle exec guard -g debug_js debug_css'; end
121120
namespace :debug do
122121
task :js do sh 'bundle exec guard -g debug_js'; end
@@ -125,6 +124,18 @@ namespace :watch do
125124
end
126125

127126

127+
#######
128+
# Hugo
129+
desc "Generate the static site into #{$hugo_dest}"
130+
task :hugo => ['clean:hugo'] do sh "hugo -d #{$hugo_dest}"; end
131+
namespace :hugo do
132+
133+
#TODO<drew.pirrone.brusse@gmail>: Add in some way to specify ip/port.
134+
desc "Run Hugo Server"
135+
task :server do sh "hugo server"; end
136+
end
137+
138+
128139
#########
129140
# Deploy
130141
desc "Build and deploy static artifacts"
@@ -133,122 +144,49 @@ task :deploy => [
133144
'deploy:fetch_archived_content',
134145
'build:js',
135146
'build:css',
136-
'build:hugo'
147+
'hugo'
137148
] do do_deploy(); end
138149
namespace :deploy do
139150
task :immediately_and_unsafely do do_deploy(); end
140151
task :fetch_archived_content do do_fetch_archived_content(); end
141152
end
142153

143-
# Generate download.yaml metadata.
144-
# This task should be run every time a new package is placed onto the
145-
# downloads server, and the updated file(s) should be tracked in Git.
146-
desc "Generate package URI information"
147-
task :gen_download_info do generate_download_yaml(); end
154+
155+
#####################
156+
# Metadata Generation
157+
#
158+
# These tasks should be run in response to a new version of any project being
159+
# made available. When a new package is uploaded to our downloads host, we will
160+
# need to run `rake metadata:generate_downloads`. When a new version or project
161+
# is added to config.yaml, run `rake metadata:generate_projects`.
162+
task :generate_metadata
163+
namespace :metadata do
164+
desc "Update all generative metadata files"
165+
task :all => ['metadata:generate_downloads', 'metadata:generate_projects']
166+
167+
desc "Generate package URI information"
168+
task :generate_downloads do generate_downloads_metadata(); end
169+
170+
desc "Generate JavaScript-readable project descriptions"
171+
task :generate_projects do generate_projects_metadata(); end
172+
end
173+
148174

149175

150176
######################################################################
151177
### Helper/Compilation functions
152178

153-
# Helper function that will print " deleting #{dir_name}" to the console, and
154-
# color the "deleting" text red.
155-
def log_dir_deletion(dir_name)
179+
# Prints " deleting #{target}" to the console, and color "deleting" red.
180+
def log_deletion(target)
156181
red = "\033[31m"
157182
nc = "\033[0m" # no color
158-
print " #{red}deleting#{nc} #{dir_name}\n"
183+
print " #{red}deleting#{nc} #{target}\n"
159184
end
160185

161-
def compile_js(debug: false)
162-
require 'sprockets'
163-
require 'yaml'
164-
require 'uglifier'
165-
166-
env = Sprockets::Environment.new(".")
167-
env.append_path $js_source
168-
169-
if (debug)
170-
#TODO<drew.pirrone.brusse@gmail>: This doesn't make anything more readable.
171-
# I don't know how to -- or if we can -- improve readability of js that's
172-
# been run through Sprockets...
173-
# env.js_compressor = Uglifier.new(
174-
# :output => {
175-
# :comments => :all,
176-
# # :preserve_line => true
177-
# },
178-
# :mangle => false,
179-
# :compress => false)
180-
else
181-
env.js_compressor = Uglifier.new(
182-
:output => {
183-
:comments => :none
184-
})
185-
end
186-
187-
# This will produce a zipped array-of-arrays in the form,
188-
# [[souce1, dest1], [source2, dest2], ..., [sourceN, destN]]
189-
# where the source files are all fo the .js, .coffee, and .erb files in the
190-
# root of $js_source, and the dest files are all equivalently-named .js files.
191-
src_dst_list = (Dir.glob("#{$js_source}/*.js")
192-
.concat Dir.glob("#{$js_source}/*.coffee")
193-
.concat Dir.glob("#{$js_source}/*.erb")
194-
).map do |file|
195-
src = File.basename file
196-
# We have to use gsub here (rather than `basename(source, ".*")`) because
197-
# e.g. 'source.coffee.erb' would turn into 'source.coffee', and we want
198-
# exactly 'source'.
199-
dst = "#{$js_dest}/#{src.gsub(/\..*/, "")}.js"
200-
[src, dst]
201-
end
202-
203-
for src, dst in src_dst_list
204-
File.open(dst, 'w') { |file| file.write env[src].to_s }
205-
log_js_write(dst)
206-
end
207-
end
208-
209-
# Helper function that will print " write #{file_name}" to the console, and
210-
# color the "write" text green. This is to match the Compass log output on file
211-
# writes.
212-
def log_js_write(file_name)
186+
# Print " write #{target}" to the console, and color "write" green. This is
187+
# designed to match the Compass log output on file writes.
188+
def log_write(target)
213189
green = "\033[32m"
214190
nc = "\033[0m" # no color
215-
print " #{green}write#{nc} #{file_name}\n"
216-
end
217-
218-
def compile_css(debug: false)
219-
# This code was largely inspired by this SO question
220-
# http://stackoverflow.com/questions/25399962/compass-from-ruby-sasscompiler-not-found
221-
# with addtional code and configuraion options drawn from:
222-
# https://github.com/Compass/compass/blob/350bcaa544f594bca972aaa29a9bdfddceee5d4f/cli/lib/compass/exec/global_options_parser.rb
223-
# https://github.com/Compass/compass/blob/350bcaa544f594bca972aaa29a9bdfddceee5d4f/cli/lib/compass/exec/project_options_parser.rb
224-
225-
#NOTE<drew.pirrone.brusse@gmail>: I made the choice here to start from the
226-
# above SO question and code snippets to make this call using the undocumented
227-
# Ruby API of Compass rather than building a shell call out of a Ruby string
228-
# and passing that to the OS layer. I don't know if it's the right choice, but
229-
# it's the choice I made. Hopefully no one gets bit by it.
230-
require 'compass'
231-
require 'compass/sass_compiler'
232-
require 'sass-css-importer'
233-
234-
Compass.configuration.add_import_path "#{$css_source}/imports"
235-
configs = {}
236-
configs[:project_path] = "."
237-
configs[:http_path] = "/"
238-
configs[:sass_path] = $css_source
239-
configs[:css_path] = $css_dest
240-
configs[:cache_path] = $cache_dir
241-
configs[:images_path] = "static/images/"
242-
configs[:output_style] = debug ? :nested : :compressed
243-
configs[:line_comments] = debug ? true : false
244-
Compass.add_configuration(configs, "basho_docs_configs")
245-
246-
# This will grab every .scss file in the $css_source directory, and run them
247-
# through Compass, generating equivalently-named .css files in the static/css
248-
# directory. We should try to keep the number of compiled sources to a minimum
249-
# though, and simply add new/parsed scss/css files to `all.scss`.
250-
compiler = Compass.sass_compiler({
251-
:only_sass_files => Dir.glob("#{$css_source}/*.scss")
252-
})
253-
compiler.compile!
191+
print " #{green}write#{nc} #{target}\n"
254192
end

0 commit comments

Comments
 (0)