diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2015-08-26 05:24:32 +0300 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2015-08-26 05:24:32 +0300 |
commit | 032cf751fff0e4b008952dedc6cda961e0035ac1 (patch) | |
tree | 93778dfb6208661798db8e7cf3d21e717e3bb675 | |
parent | 44fa20c19b28a4207cbaea901b196bec585085f4 (diff) |
Fix updater caching, use upstream version for variables
-rw-r--r-- | assets/javascripts/bootstrap-sprockets.js | 4 | ||||
-rw-r--r-- | lib/bootstrap/version.rb | 4 | ||||
-rw-r--r-- | tasks/updater.rb | 8 | ||||
-rw-r--r-- | tasks/updater/network.rb | 14 | ||||
-rw-r--r-- | tasks/updater/scss_conversion.rb | 7 | ||||
-rw-r--r-- | templates/project/_bootstrap-variables.sass | 2 |
6 files changed, 21 insertions, 18 deletions
diff --git a/assets/javascripts/bootstrap-sprockets.js b/assets/javascripts/bootstrap-sprockets.js index 0a457c9..24c5a5d 100644 --- a/assets/javascripts/bootstrap-sprockets.js +++ b/assets/javascripts/bootstrap-sprockets.js @@ -3,9 +3,9 @@ //= require ./bootstrap/carousel //= require ./bootstrap/collapse //= require ./bootstrap/dropdown +//= require ./bootstrap/modal +//= require ./bootstrap/scrollspy //= require ./bootstrap/tab //= require ./bootstrap/util -//= require ./bootstrap/scrollspy -//= require ./bootstrap/modal //= require ./bootstrap/tooltip //= require ./bootstrap/popover diff --git a/lib/bootstrap/version.rb b/lib/bootstrap/version.rb index 0b27ed3..6715485 100644 --- a/lib/bootstrap/version.rb +++ b/lib/bootstrap/version.rb @@ -1,4 +1,4 @@ module Bootstrap - VERSION = '3.3.5.1' - BOOTSTRAP_SHA = 'v4-dev' + VERSION = '4.0.0.dev' + BOOTSTRAP_SHA = '4b33684cd65b0f3dd6f9973f226db572047672ff' end diff --git a/tasks/updater.rb b/tasks/updater.rb index 5f8b386..c0417f8 100644 --- a/tasks/updater.rb +++ b/tasks/updater.rb @@ -55,8 +55,6 @@ class Updater puts " twbs cache: #{@cache_path}" puts '-' * 60 - FileUtils.rm_rf(@cache_path) - @save_to.each { |_, v| FileUtils.mkdir_p(v) } update_scss_assets @@ -70,10 +68,14 @@ class Updater File.open(path, mode) { |file| file.write(content) } end + def upstream_version + @upstream_version ||= get_json(file_url 'package.json')['version'] + end + # Update version.rb file with BOOTSTRAP_SHA def store_version path = 'lib/bootstrap/version.rb' - content = File.read(path).sub(/BOOTSTRAP_SHA\s*=\s*['"][\w]+['"]/, "BOOTSTRAP_SHA = '#@branch_sha'") + content = File.read(path).sub(/BOOTSTRAP_SHA\s*=\s*['"][^'"]*['"]/, "BOOTSTRAP_SHA = '#@branch_sha'") File.open(path, 'w') { |f| f.write(content) } end end diff --git a/tasks/updater/network.rb b/tasks/updater/network.rb index 1b85b7a..3625ba1 100644 --- a/tasks/updater/network.rb +++ b/tasks/updater/network.rb @@ -11,15 +11,19 @@ class Updater get_tree(get_tree_sha(dir), recursive)['tree'].select { |f| f['type'] == 'blob' }.map { |f| f['path'] } end + def file_url(path) + "https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}" + end + def read_files(path, files) - full_path = "https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}" + path_url = file_url path contents = read_cached_files(path, files) - log_http_get_files contents.keys, full_path, true if contents.keys + log_http_get_files contents.keys, path_url, true if contents.keys files -= contents.keys - log_http_get_files files, full_path, false + log_http_get_files files, path_url, false files.map do |name| Thread.start { - contents[name] = open("#{full_path}/#{name}").read + contents[name] = open("#{path_url}/#{name}").read Thread.exclusive { write_cached_files path, name => contents[name] } } end.each(&:join) @@ -65,7 +69,7 @@ class Updater # get sha of the branch (= the latest commit) def get_branch_sha @branch_sha ||= begin - if @branch + "\n" == %x[git rev-parse -- #@branch] + if @branch =~ /\A[0-9a-f]{40,}\z/ @branch else cmd = "git ls-remote #{Shellwords.escape "https://github.com/#@repo"} #@branch" diff --git a/tasks/updater/scss_conversion.rb b/tasks/updater/scss_conversion.rb index d885ff1..ed59324 100644 --- a/tasks/updater/scss_conversion.rb +++ b/tasks/updater/scss_conversion.rb @@ -4,6 +4,7 @@ class Updater log_status 'Updating scss...' save_to = @save_to[:scss] contents = {} + bootstrap_scss_files = get_paths_by_type('scss', /\.scss$/) read_files('scss', bootstrap_scss_files).each do |name, file| contents[name] = file save_file("#{save_to}/#{name}", file) @@ -26,13 +27,9 @@ class Updater log_status 'Generating variable template file' save_file 'templates/project/_bootstrap-variables.sass', - "// Override Bootstrap variables here (defaults from bootstrap-sass v#{Bootstrap::VERSION}):\n\n" + + "// Override Bootstrap variables here (defaults from bootstrap v#{upstream_version}):\n\n" + File.read("#{save_to}/_variables.scss").lines[1..-1].join.gsub(/^(?=\$|\))/, '// ').gsub(/ !default/, '') end end - - def bootstrap_scss_files - @bootstrap_scss_files ||= get_paths_by_type('scss', /\.scss$/) - end end diff --git a/templates/project/_bootstrap-variables.sass b/templates/project/_bootstrap-variables.sass index 24ee9a8..c9dd855 100644 --- a/templates/project/_bootstrap-variables.sass +++ b/templates/project/_bootstrap-variables.sass @@ -1,4 +1,4 @@ -// Override Bootstrap variables here (defaults from bootstrap-sass v3.3.5.1): +// Override Bootstrap variables here (defaults from bootstrap v4.0.0-alpha): // // Copy settings from this file into the provided `_custom.scss` to override |