Skip to content

Commit 032cf75

Browse files
committed
Fix updater caching, use upstream version for variables
1 parent 44fa20c commit 032cf75

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

assets/javascripts/bootstrap-sprockets.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//= require ./bootstrap/carousel
44
//= require ./bootstrap/collapse
55
//= require ./bootstrap/dropdown
6+
//= require ./bootstrap/modal
7+
//= require ./bootstrap/scrollspy
68
//= require ./bootstrap/tab
79
//= require ./bootstrap/util
8-
//= require ./bootstrap/scrollspy
9-
//= require ./bootstrap/modal
1010
//= require ./bootstrap/tooltip
1111
//= require ./bootstrap/popover

lib/bootstrap/version.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Bootstrap
2-
VERSION = '3.3.5.1'
3-
BOOTSTRAP_SHA = 'v4-dev'
2+
VERSION = '4.0.0.dev'
3+
BOOTSTRAP_SHA = '4b33684cd65b0f3dd6f9973f226db572047672ff'
44
end

tasks/updater.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ def update_bootstrap
5555
puts " twbs cache: #{@cache_path}"
5656
puts '-' * 60
5757

58-
FileUtils.rm_rf(@cache_path)
59-
6058
@save_to.each { |_, v| FileUtils.mkdir_p(v) }
6159

6260
update_scss_assets
@@ -70,10 +68,14 @@ def save_file(path, content, mode='w')
7068
File.open(path, mode) { |file| file.write(content) }
7169
end
7270

71+
def upstream_version
72+
@upstream_version ||= get_json(file_url 'package.json')['version']
73+
end
74+
7375
# Update version.rb file with BOOTSTRAP_SHA
7476
def store_version
7577
path = 'lib/bootstrap/version.rb'
76-
content = File.read(path).sub(/BOOTSTRAP_SHA\s*=\s*['"][\w]+['"]/, "BOOTSTRAP_SHA = '#@branch_sha'")
78+
content = File.read(path).sub(/BOOTSTRAP_SHA\s*=\s*['"][^'"]*['"]/, "BOOTSTRAP_SHA = '#@branch_sha'")
7779
File.open(path, 'w') { |f| f.write(content) }
7880
end
7981
end

tasks/updater/network.rb

+9-5
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ def get_file_paths(dir, recursive = true)
1111
get_tree(get_tree_sha(dir), recursive)['tree'].select { |f| f['type'] == 'blob' }.map { |f| f['path'] }
1212
end
1313

14+
def file_url(path)
15+
"https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}"
16+
end
17+
1418
def read_files(path, files)
15-
full_path = "https://raw.githubusercontent.com/#%3C/span%3E%3Cspan%20class="pl-c1 x">@repo/#@branch_sha/#{path}"
19+
path_url = file_url path
1620
contents = read_cached_files(path, files)
17-
log_http_get_files contents.keys, full_path, true if contents.keys
21+
log_http_get_files contents.keys, path_url, true if contents.keys
1822
files -= contents.keys
19-
log_http_get_files files, full_path, false
23+
log_http_get_files files, path_url, false
2024
files.map do |name|
2125
Thread.start {
22-
contents[name] = open("#{full_path}/#{name}").read
26+
contents[name] = open("#{path_url}/#{name}").read
2327
Thread.exclusive { write_cached_files path, name => contents[name] }
2428
}
2529
end.each(&:join)
@@ -65,7 +69,7 @@ def get_file(url)
6569
# get sha of the branch (= the latest commit)
6670
def get_branch_sha
6771
@branch_sha ||= begin
68-
if @branch + "\n" == %x[git rev-parse -- #@branch]
72+
if @branch =~ /\A[0-9a-f]{40,}\z/
6973
@branch
7074
else
7175
cmd = "git ls-remote #{Shellwords.escape "https://github.com/#@repo"} #@branch"

tasks/updater/scss_conversion.rb

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ def update_scss_assets
44
log_status 'Updating scss...'
55
save_to = @save_to[:scss]
66
contents = {}
7+
bootstrap_scss_files = get_paths_by_type('scss', /\.scss$/)
78
read_files('scss', bootstrap_scss_files).each do |name, file|
89
contents[name] = file
910
save_file("#{save_to}/#{name}", file)
@@ -26,13 +27,9 @@ def update_scss_assets
2627
log_status 'Generating variable template file'
2728

2829
save_file 'templates/project/_bootstrap-variables.sass',
29-
"// Override Bootstrap variables here (defaults from bootstrap-sass v#{Bootstrap::VERSION}):\n\n" +
30+
"// Override Bootstrap variables here (defaults from bootstrap v#{upstream_version}):\n\n" +
3031
File.read("#{save_to}/_variables.scss").lines[1..-1].join.gsub(/^(?=\$|\))/, '// ').gsub(/ !default/, '')
3132

3233
end
3334
end
34-
35-
def bootstrap_scss_files
36-
@bootstrap_scss_files ||= get_paths_by_type('scss', /\.scss$/)
37-
end
3835
end

templates/project/_bootstrap-variables.sass

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Override Bootstrap variables here (defaults from bootstrap-sass v3.3.5.1):
1+
// Override Bootstrap variables here (defaults from bootstrap v4.0.0-alpha):
22
33
//
44
// Copy settings from this file into the provided `_custom.scss` to override

0 commit comments

Comments
 (0)