Skip to content

Commit 555bec3

Browse files
authored
Merge pull request #2202 from basho/dpb/build_system_improvements
Misc Build System Improvements
2 parents 4f42ffd + 0cb53da commit 555bec3

File tree

3 files changed

+43
-28
lines changed

3 files changed

+43
-28
lines changed

Rakefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ task :clean => ['clean:js', 'clean:css']
5555
namespace :clean do
5656
desc "Clean dynamically generated JS"
5757
task :js do
58-
js_file_list = Dir["#{$js_dest}/**/**"]
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) }
5961
js_file_list.each do |f|
6062
log_deletion(f)
6163
FileUtils.rm(f)
6264
end
6365
end
6466
desc "Clean dynamically generated CSS"
6567
task :css do
66-
css_file_list = Dir["#{$css_dest}/**/**"]
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) }
6771
css_file_list.each do |f|
6872
log_deletion(f)
6973
FileUtils.rm(f)
@@ -88,13 +92,14 @@ namespace :build do
8892
################
8993
# Build : Debug
9094
desc "Compile human-readable JS and compile human-readable CSS"
91-
task :debug => ['clean', 'build:debug:js', 'build:debug:css']
95+
task :debug => ["#{$js_dest}", "#{$css_dest}",
96+
'build:debug:js', 'build:debug:css']
9297
namespace :debug do
9398
desc "Compile human-readable JS"
94-
task :js => ["#{$js_dest}", 'clean:js'] do compile_js(debug: true); end
99+
task :js => ["#{$js_dest}"] do compile_js(debug: true); end
95100

96101
desc "Compile human-readable CSS"
97-
task :css => ["#{$css_dest}", 'clean:css'] do compile_css(debug: true); end
102+
task :css => ["#{$css_dest}"] do compile_css(debug: true); end
98103
end
99104
end
100105

dynamic/Guardfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ directories %w(dynamic data) \
2929

3030
group :js do
3131
guard 'rake', :task => 'build:js' do
32-
watch(%r{^dynamic/js/.*$})
33-
watch(%r{^data/versions.yml})
32+
watch(%r{^dynamic/js/.*\.js$})
33+
watch(%r{^dynamic/js/.*\.coffee$})
3434
end
3535
end
3636

@@ -44,8 +44,8 @@ end
4444

4545
group :debug_js do
4646
guard 'rake', :task => 'build:debug:js' do
47-
watch(%r{^dynamic/js/.*$})
48-
watch(%r{^data/versions.yml})
47+
watch(%r{^dynamic/js/.*\.js$})
48+
watch(%r{^dynamic/js/.*\.coffee$})
4949
end
5050
end
5151

rake_libs/s3_deploy.rb

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def do_fetch_archived_content()
77
# Fetch and extract the archived content that we want to survive from the
88
# Middleman website.
9-
puts("Verifying archived content...")
9+
puts("Verifying the archived tarball is present and correct...")
1010
# Verify that the tar.bz2 is present.
1111
if (not File.file?(File.join(Dir.pwd, "#{$archive_name}")))
1212
if (`which wget`.empty?)
@@ -57,32 +57,42 @@ def do_fetch_archived_content()
5757
end
5858
end
5959

60-
puts("Verifying archived content extraction...")
61-
puts(" Please note, this only checks for directories.\n"\
62-
" If something went wrong with a previous extraction or if any "\
63-
"of the extracted files were modified, please run \`git clean "\
64-
"-xdf static/\` and re-run this deploy script.")
65-
#TODO: Consider if this is a good idea or not. I'm leaning towards not.
66-
should_extract = (
67-
(not File.exist?("static/css/standalone")) ||
68-
(not File.exist?("static/js/standalone")) ||
69-
(not File.exist?("static/riak")) ||
70-
(not File.exist?("static/riakcs")) ||
71-
(not File.exist?("static/riakee")) ||
72-
(not File.exist?("static/shared")) )
73-
74-
if (should_extract)
60+
puts("Verifying archived content extraction by checking direcotry tree...")
61+
all_dirs_present = ( (File.exist?("static/css/standalone")) &&
62+
(File.exist?("static/js/standalone")) &&
63+
(File.exist?("static/riak/1.4.12")) &&
64+
(File.exist?("static/riakcs/1.5.4")) &&
65+
(File.exist?("static/riakee")) &&
66+
(File.exist?("static/shared")) )
67+
any_dirs_present = ( (File.exist?("static/css/standalone")) ||
68+
(File.exist?("static/js/standalone")) ||
69+
(File.exist?("static/riak/1.4.12")) ||
70+
(File.exist?("static/riakcs/1.5.4")) ||
71+
(File.exist?("static/riakee")) ||
72+
(File.exist?("static/shared")) )
73+
if (not all_dirs_present and any_dirs_present)
74+
Kernel.abort("ERRPR: The static/ directory is verifiably corrupt.\n"\
75+
" Please run \`git clean -xdf static/\` to clear out "\
76+
"the malformed files, and re-run this deploy script.")
77+
elsif (not any_dirs_present)
7578
puts("Extracting #{$archive_name} (this may take a lot of time)...")
7679
successful = system("tar -xjf #{$archive_name} -C static")
77-
7880
if (not successful)
7981
Kernel.abort("ERROR: #{$archive_name} failed to extract.\n"\
80-
" I... actually don't know why. Not sure how to "\
81-
"extract error messages from this system call.")
82+
" The failure message should have been printed to "\
83+
"stdout and be visible above.")
8284
end
85+
else
86+
puts(" Archived content directory tree verified.\n"\
87+
" NOTE: File integrity is NOT checked here.\n"\
88+
" As such, it is advisable to periodically clean out the "\
89+
"static/ directory that this archive is extracted into.\n"\
90+
" To do so, please run \`git clean -xdf static/\`, and "\
91+
"re-run this deploy script.")
8392
end
8493
end
8594

95+
8696
# Once the Hugo site has been fully and correctly generated, we can upload the
8797
# updated and new -- and delete the no longer generated -- files to/from our S3
8898
# bucket, and send out CloudFront invalidation requests to propagate those

0 commit comments

Comments
 (0)