bootstrap-propshaft 5.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +14 -0
  3. data/.github/workflows/ci.yml +61 -0
  4. data/.gitignore +19 -0
  5. data/CHANGELOG.md +25 -0
  6. data/Gemfile +12 -0
  7. data/LICENSE +21 -0
  8. data/README.md +138 -0
  9. data/Rakefile +89 -0
  10. data/assets/javascripts/bootstrap/alert.js +89 -0
  11. data/assets/javascripts/bootstrap/base-component.js +83 -0
  12. data/assets/javascripts/bootstrap/button.js +78 -0
  13. data/assets/javascripts/bootstrap/carousel.js +387 -0
  14. data/assets/javascripts/bootstrap/collapse.js +248 -0
  15. data/assets/javascripts/bootstrap/dom/data.js +62 -0
  16. data/assets/javascripts/bootstrap/dom/event-handler.js +236 -0
  17. data/assets/javascripts/bootstrap/dom/manipulator.js +71 -0
  18. data/assets/javascripts/bootstrap/dom/selector-engine.js +103 -0
  19. data/assets/javascripts/bootstrap/dropdown.js +401 -0
  20. data/assets/javascripts/bootstrap/modal.js +319 -0
  21. data/assets/javascripts/bootstrap/offcanvas.js +245 -0
  22. data/assets/javascripts/bootstrap/popover.js +95 -0
  23. data/assets/javascripts/bootstrap/scrollspy.js +274 -0
  24. data/assets/javascripts/bootstrap/tab.js +284 -0
  25. data/assets/javascripts/bootstrap/toast.js +198 -0
  26. data/assets/javascripts/bootstrap/tooltip.js +545 -0
  27. data/assets/javascripts/bootstrap/util/backdrop.js +139 -0
  28. data/assets/javascripts/bootstrap/util/component-functions.js +41 -0
  29. data/assets/javascripts/bootstrap/util/config.js +67 -0
  30. data/assets/javascripts/bootstrap/util/focustrap.js +113 -0
  31. data/assets/javascripts/bootstrap/util/index.js +281 -0
  32. data/assets/javascripts/bootstrap/util/sanitizer.js +110 -0
  33. data/assets/javascripts/bootstrap/util/scrollbar.js +112 -0
  34. data/assets/javascripts/bootstrap/util/swipe.js +134 -0
  35. data/assets/javascripts/bootstrap/util/template-factory.js +150 -0
  36. data/assets/javascripts/bootstrap-global-this-define.js +6 -0
  37. data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
  38. data/assets/javascripts/bootstrap-sprockets.js +28 -0
  39. data/assets/javascripts/bootstrap.js +4493 -0
  40. data/assets/javascripts/bootstrap.min.js +6 -0
  41. data/assets/stylesheets/_bootstrap-grid.scss +62 -0
  42. data/assets/stylesheets/_bootstrap-reboot.scss +10 -0
  43. data/assets/stylesheets/_bootstrap-utilities.scss +19 -0
  44. data/assets/stylesheets/_bootstrap.scss +52 -0
  45. data/assets/stylesheets/bootstrap/_accordion.scss +158 -0
  46. data/assets/stylesheets/bootstrap/_alert.scss +68 -0
  47. data/assets/stylesheets/bootstrap/_badge.scss +38 -0
  48. data/assets/stylesheets/bootstrap/_breadcrumb.scss +40 -0
  49. data/assets/stylesheets/bootstrap/_button-group.scss +142 -0
  50. data/assets/stylesheets/bootstrap/_buttons.scss +207 -0
  51. data/assets/stylesheets/bootstrap/_card.scss +239 -0
  52. data/assets/stylesheets/bootstrap/_carousel.scss +244 -0
  53. data/assets/stylesheets/bootstrap/_close.scss +63 -0
  54. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  55. data/assets/stylesheets/bootstrap/_dropdown.scss +250 -0
  56. data/assets/stylesheets/bootstrap/_forms.scss +9 -0
  57. data/assets/stylesheets/bootstrap/_functions.scss +302 -0
  58. data/assets/stylesheets/bootstrap/_grid.scss +39 -0
  59. data/assets/stylesheets/bootstrap/_helpers.scss +12 -0
  60. data/assets/stylesheets/bootstrap/_images.scss +42 -0
  61. data/assets/stylesheets/bootstrap/_list-group.scss +197 -0
  62. data/assets/stylesheets/bootstrap/_maps.scss +174 -0
  63. data/assets/stylesheets/bootstrap/_mixins.scss +42 -0
  64. data/assets/stylesheets/bootstrap/_modal.scss +237 -0
  65. data/assets/stylesheets/bootstrap/_nav.scss +197 -0
  66. data/assets/stylesheets/bootstrap/_navbar.scss +289 -0
  67. data/assets/stylesheets/bootstrap/_offcanvas.scss +146 -0
  68. data/assets/stylesheets/bootstrap/_pagination.scss +109 -0
  69. data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
  70. data/assets/stylesheets/bootstrap/_popover.scss +196 -0
  71. data/assets/stylesheets/bootstrap/_progress.scss +68 -0
  72. data/assets/stylesheets/bootstrap/_reboot.scss +611 -0
  73. data/assets/stylesheets/bootstrap/_root.scss +187 -0
  74. data/assets/stylesheets/bootstrap/_spinners.scss +85 -0
  75. data/assets/stylesheets/bootstrap/_tables.scss +171 -0
  76. data/assets/stylesheets/bootstrap/_toasts.scss +73 -0
  77. data/assets/stylesheets/bootstrap/_tooltip.scss +119 -0
  78. data/assets/stylesheets/bootstrap/_transitions.scss +27 -0
  79. data/assets/stylesheets/bootstrap/_type.scss +106 -0
  80. data/assets/stylesheets/bootstrap/_utilities.scss +806 -0
  81. data/assets/stylesheets/bootstrap/_variables-dark.scss +87 -0
  82. data/assets/stylesheets/bootstrap/_variables.scss +1747 -0
  83. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +95 -0
  84. data/assets/stylesheets/bootstrap/forms/_form-check.scss +189 -0
  85. data/assets/stylesheets/bootstrap/forms/_form-control.scss +214 -0
  86. data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
  87. data/assets/stylesheets/bootstrap/forms/_form-select.scss +80 -0
  88. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  89. data/assets/stylesheets/bootstrap/forms/_input-group.scss +132 -0
  90. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  91. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  92. data/assets/stylesheets/bootstrap/helpers/_clearfix.scss +3 -0
  93. data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +7 -0
  94. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +30 -0
  95. data/assets/stylesheets/bootstrap/helpers/_focus-ring.scss +5 -0
  96. data/assets/stylesheets/bootstrap/helpers/_icon-link.scss +25 -0
  97. data/assets/stylesheets/bootstrap/helpers/_position.scss +36 -0
  98. data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
  99. data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
  100. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  101. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  102. data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
  103. data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
  104. data/assets/stylesheets/bootstrap/mixins/_alert.scss +18 -0
  105. data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
  106. data/assets/stylesheets/bootstrap/mixins/_banner.scss +7 -0
  107. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +78 -0
  108. data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +18 -0
  109. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +127 -0
  110. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +70 -0
  111. data/assets/stylesheets/bootstrap/mixins/_caret.scss +69 -0
  112. data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +9 -0
  113. data/assets/stylesheets/bootstrap/mixins/_color-mode.scss +21 -0
  114. data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
  115. data/assets/stylesheets/bootstrap/mixins/_container.scss +11 -0
  116. data/assets/stylesheets/bootstrap/mixins/_deprecate.scss +10 -0
  117. data/assets/stylesheets/bootstrap/mixins/_forms.scss +153 -0
  118. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +47 -0
  119. data/assets/stylesheets/bootstrap/mixins/_grid.scss +151 -0
  120. data/assets/stylesheets/bootstrap/mixins/_image.scss +16 -0
  121. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +26 -0
  122. data/assets/stylesheets/bootstrap/mixins/_lists.scss +7 -0
  123. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +10 -0
  124. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +17 -0
  125. data/assets/stylesheets/bootstrap/mixins/_resize.scss +6 -0
  126. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +24 -0
  127. data/assets/stylesheets/bootstrap/mixins/_text-truncate.scss +8 -0
  128. data/assets/stylesheets/bootstrap/mixins/_transition.scss +26 -0
  129. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +97 -0
  130. data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +33 -0
  131. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  132. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +348 -0
  133. data/bootstrap.gemspec +39 -0
  134. data/lib/bootstrap/engine.rb +22 -0
  135. data/lib/bootstrap/version.rb +6 -0
  136. data/lib/bootstrap.rb +75 -0
  137. data/tasks/updater/js.rb +92 -0
  138. data/tasks/updater/logger.rb +57 -0
  139. data/tasks/updater/network.rb +109 -0
  140. data/tasks/updater/scss.rb +26 -0
  141. data/tasks/updater.rb +67 -0
  142. data/test/dummy_rails/README.rdoc +3 -0
  143. data/test/dummy_rails/Rakefile +6 -0
  144. data/test/dummy_rails/app/assets/config/manifest.js +3 -0
  145. data/test/dummy_rails/app/assets/images/.keep +0 -0
  146. data/test/dummy_rails/app/assets/javascripts/application.js +8 -0
  147. data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
  148. data/test/dummy_rails/app/assets/stylesheets/application.sass +4 -0
  149. data/test/dummy_rails/app/controllers/application_controller.rb +5 -0
  150. data/test/dummy_rails/app/controllers/pages_controller.rb +4 -0
  151. data/test/dummy_rails/app/helpers/application_helper.rb +2 -0
  152. data/test/dummy_rails/app/views/layouts/application.html.erb +16 -0
  153. data/test/dummy_rails/app/views/pages/root.html +89 -0
  154. data/test/dummy_rails/config/application.rb +32 -0
  155. data/test/dummy_rails/config/boot.rb +5 -0
  156. data/test/dummy_rails/config/environment.rb +5 -0
  157. data/test/dummy_rails/config/environments/development.rb +23 -0
  158. data/test/dummy_rails/config/environments/production.rb +82 -0
  159. data/test/dummy_rails/config/environments/test.rb +38 -0
  160. data/test/dummy_rails/config/initializers/backtrace_silencers.rb +7 -0
  161. data/test/dummy_rails/config/initializers/filter_parameter_logging.rb +4 -0
  162. data/test/dummy_rails/config/initializers/inflections.rb +16 -0
  163. data/test/dummy_rails/config/initializers/mime_types.rb +5 -0
  164. data/test/dummy_rails/config/initializers/secret_token.rb +18 -0
  165. data/test/dummy_rails/config/initializers/session_store.rb +3 -0
  166. data/test/dummy_rails/config/initializers/wrap_parameters.rb +14 -0
  167. data/test/dummy_rails/config/locales/en.yml +3 -0
  168. data/test/dummy_rails/config/locales/es.yml +3 -0
  169. data/test/dummy_rails/config/routes.rb +3 -0
  170. data/test/dummy_rails/config.ru +4 -0
  171. data/test/dummy_rails/log/.keep +0 -0
  172. data/test/gemfiles/rails_4_2.gemfile +7 -0
  173. data/test/gemfiles/rails_5_0.gemfile +8 -0
  174. data/test/gemfiles/rails_5_1.gemfile +8 -0
  175. data/test/gemfiles/rails_5_2.gemfile +8 -0
  176. data/test/gemfiles/rails_6_0.gemfile +8 -0
  177. data/test/gemfiles/rails_6_1.gemfile +8 -0
  178. data/test/gemfiles/rails_7_0_dartsass.gemfile +8 -0
  179. data/test/gemfiles/rails_7_0_sassc.gemfile +8 -0
  180. data/test/rails_test.rb +24 -0
  181. data/test/support/dummy_rails_integration.rb +31 -0
  182. data/test/support/reporting.rb +27 -0
  183. data/test/test_helper.rb +42 -0
  184. data/test/test_helper_rails.rb +6 -0
  185. metadata +471 -0
@@ -0,0 +1,92 @@
1
+ require 'pathname'
2
+ require 'tsort'
3
+
4
+ class Updater
5
+ module Js
6
+ INLINED_SRCS = %w[].freeze
7
+
8
+ def update_javascript_assets
9
+ log_status 'Updating javascripts...'
10
+ save_to = @save_to[:js]
11
+ read_files('js/dist', bootstrap_js_files).each do |name, content|
12
+ save_file("#{save_to}/#{name}", remove_source_mapping_url(content))
13
+ end
14
+ log_processed "#{bootstrap_js_files * ' '}"
15
+
16
+ log_status 'Updating javascript manifest'
17
+ manifest = "//= require ./bootstrap-global-this-define\n"
18
+ bootstrap_js_files.each do |name|
19
+ name = name.gsub(/\.js$/, '')
20
+ manifest << "//= require ./bootstrap/#{name}\n"
21
+ end
22
+ manifest << "//= require ./bootstrap-global-this-undefine\n"
23
+ dist_js = read_files('dist/js', %w(bootstrap.js bootstrap.min.js))
24
+ {
25
+ 'assets/javascripts/bootstrap-global-this-define.js' => <<~JS,
26
+ // Set a `globalThis` so that bootstrap components are defined on window.bootstrap instead of window.
27
+ window['bootstrap'] = {
28
+ "@popperjs/core": window.Popper,
29
+ _originalGlobalThis: window['globalThis']
30
+ };
31
+ window['globalThis'] = window['bootstrap'];
32
+ JS
33
+ 'assets/javascripts/bootstrap-global-this-undefine.js' => <<~JS,
34
+ window['globalThis'] = window['bootstrap']._originalGlobalThis;
35
+ window['bootstrap']._originalGlobalThis = null;
36
+ JS
37
+ 'assets/javascripts/bootstrap-sprockets.js' => manifest,
38
+ 'assets/javascripts/bootstrap.js' => dist_js['bootstrap.js'],
39
+ 'assets/javascripts/bootstrap.min.js' => dist_js['bootstrap.min.js'],
40
+ }.each do |path, content|
41
+ save_file path, remove_source_mapping_url(content)
42
+ log_processed path
43
+ end
44
+ end
45
+
46
+ def bootstrap_js_files
47
+ @bootstrap_js_files ||= begin
48
+ src_files = get_paths_by_type('js/src', /\.js$/) - INLINED_SRCS
49
+ puts "src_files: #{src_files.inspect}"
50
+ imports = Deps.new
51
+ # Get the imports from the ES6 files to order requires correctly.
52
+ read_files('js/src', src_files).each do |name, content|
53
+ file_imports = content.scan(%r{import *(?:[a-zA-Z]*|\{[a-zA-Z ,]*\}) *from '([\w/.-]+)}).flatten(1).map do |f|
54
+ Pathname.new(name).dirname.join(f).cleanpath.to_s
55
+ end.uniq
56
+ imports.add name, *(file_imports - INLINED_SRCS)
57
+ end
58
+ imports.tsort
59
+ end
60
+ end
61
+
62
+ def remove_source_mapping_url(content)
63
+ content.sub(%r{^//# sourceMappingURL=.*\n?\z}, '')
64
+ end
65
+
66
+ class Deps
67
+ include TSort
68
+
69
+ def initialize
70
+ @imports = {}
71
+ end
72
+
73
+ def add(from, *tos)
74
+ imports = (@imports[from] ||= [])
75
+ imports.push(*tos)
76
+ imports.sort!
77
+ end
78
+
79
+ def tsort_each_child(node, &block)
80
+ node_imports = @imports[node]
81
+ if node_imports.nil?
82
+ raise "No imports found for #{node.inspect}\nImports:\n#{@imports.inspect}"
83
+ end
84
+ node_imports.each(&block)
85
+ end
86
+
87
+ def tsort_each_node(&block)
88
+ @imports.each_key(&block)
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,57 @@
1
+ class Updater
2
+ class Logger
3
+ include Term::ANSIColor
4
+
5
+ def log_status(status)
6
+ puts bold status
7
+ end
8
+
9
+ def log_file_info(s)
10
+ puts " #{magenta s}"
11
+ end
12
+
13
+ def log_transform(*args, from: caller[1][/`.*'/][1..-2].sub(/^block in /, ''))
14
+ puts " #{cyan from}#{cyan ": #{args * ', '}" unless args.empty?}"
15
+ end
16
+
17
+ def log_processing(name)
18
+ puts yellow " #{File.basename(name)}"
19
+ end
20
+
21
+ def log_processed(name)
22
+ puts green " #{name}"
23
+ end
24
+
25
+ def log_http_get_file(url, cached = false)
26
+ s = " #{'CACHED ' if cached}GET #{url}..."
27
+ if cached
28
+ puts dark green s
29
+ else
30
+ puts dark cyan s
31
+ end
32
+ end
33
+
34
+ def log_http_get_files(files, from, cached = false)
35
+ return if files.empty?
36
+ s = " #{'CACHED ' if cached}GET #{files.length} files from #{from} #{files * ' '}..."
37
+ if cached
38
+ puts dark green s
39
+ else
40
+ puts dark cyan s
41
+ end
42
+ end
43
+
44
+ def puts(*args)
45
+ STDERR.puts *args unless @silence
46
+ end
47
+
48
+ alias log puts
49
+
50
+ def silence_log
51
+ @silence = true
52
+ yield
53
+ ensure
54
+ @silence = false
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,109 @@
1
+ require 'shellwords'
2
+ class Updater
3
+ module Network
4
+ protected
5
+
6
+ WRITE_FILES_MUTEX = Mutex.new
7
+
8
+ def get_paths_by_type(dir, file_re, recursive = true)
9
+ get_file_paths(dir, recursive).select { |path| path =~ file_re }
10
+ end
11
+
12
+ def get_file_paths(dir, recursive = true)
13
+ get_tree(get_tree_sha(dir), recursive)['tree'].select { |f| f['type'] == 'blob' }.map { |f| f['path'] }
14
+ end
15
+
16
+ def file_url(path)
17
+ "https://raw.githubusercontent.com/#@repo/#@branch_sha/#{path}"
18
+ end
19
+
20
+ def read_files(path, files)
21
+ path_url = file_url path
22
+ contents = read_cached_files(path, files)
23
+ log_http_get_files contents.keys, path_url, true if contents.keys
24
+ files -= contents.keys
25
+ log_http_get_files files, path_url, false
26
+ files.map do |name|
27
+ Thread.start {
28
+ begin
29
+ url = "#{path_url}/#{name}"
30
+ contents[name] = URI.open(url).read
31
+ rescue Exception => e
32
+ log "Error downloading #{url}: #{e}"
33
+ exit 1
34
+ end
35
+ WRITE_FILES_MUTEX.synchronize { write_cached_files path, name => contents[name] }
36
+ }
37
+ end.each(&:join)
38
+ contents
39
+ end
40
+
41
+ def read_cached_files(path, files)
42
+ full_path = "#@cache_path/#@branch_sha/#{path}"
43
+ contents = {}
44
+ if File.directory?(full_path)
45
+ files.each do |name|
46
+ path = "#{full_path}/#{name}"
47
+ contents[name] = File.read(path, mode: 'rb') if File.exist?(path)
48
+ end
49
+ end
50
+ contents
51
+ end
52
+
53
+ def write_cached_files(path, files)
54
+ full_path = "./#@cache_path/#@branch_sha/#{path}"
55
+ files.each do |name, content|
56
+ FileUtils.mkdir_p File.dirname(File.join(full_path, name))
57
+ File.open("#{full_path}/#{name}", 'wb') { |f| f.write content }
58
+ end
59
+ end
60
+
61
+
62
+ def get_file(url)
63
+ uri = URI(url)
64
+ cache_path = "./#@cache_path#{uri.path}#{uri.query.tr('?&=', '-') if uri.query}"
65
+ FileUtils.mkdir_p File.dirname(cache_path)
66
+ if File.exist?(cache_path)
67
+ log_http_get_file url, true
68
+ File.read(cache_path, mode: 'rb')
69
+ else
70
+ log_http_get_file url, false
71
+ content = URI.open(url).read
72
+ File.open(cache_path, 'wb') { |f| f.write content }
73
+ content
74
+ end
75
+ end
76
+
77
+ # get sha of the branch (= the latest commit)
78
+ def get_branch_sha
79
+ @branch_sha ||= begin
80
+ if @branch =~ /\A[0-9a-f]{40,}\z/
81
+ @branch
82
+ else
83
+ cmd = "git ls-remote #{Shellwords.escape "https://github.com/#@repo"} #@branch"
84
+ log cmd
85
+ result = %x[#{cmd}]
86
+ raise 'Could not get branch sha!' unless $?.success? && !result.empty?
87
+ result.split(/\s+/).first
88
+ end
89
+ end
90
+ end
91
+
92
+ # Get the sha of a dir
93
+ def get_tree_sha(dir, tree = get_trees)
94
+ tree['tree'].find { |t| t['path'] == dir }['sha']
95
+ end
96
+
97
+ def get_trees
98
+ @trees ||= get_tree(@branch_sha)
99
+ end
100
+
101
+ def get_tree(sha, recursive = true)
102
+ get_json("https://api.github.com/repos/#@repo/git/trees/#{sha}#{'?recursive=1' if recursive}")
103
+ end
104
+
105
+ def get_json(url)
106
+ JSON.parse get_file(url)
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,26 @@
1
+ class Updater
2
+ module Scss
3
+ def update_scss_assets
4
+ log_status 'Updating scss...'
5
+ save_to = @save_to[:scss]
6
+ contents = {}
7
+ bootstrap_scss_files = get_paths_by_type('scss', /\.scss$/).reject { |p| p.start_with?('tests/') }
8
+ read_files('scss', bootstrap_scss_files).each do |name, file|
9
+ contents[name] = file
10
+ save_file("#{save_to}/#{name}", file)
11
+ end
12
+ log_processed "#{bootstrap_scss_files * ' '}"
13
+
14
+ log_status 'Updating scss main files'
15
+ %w(bootstrap bootstrap-grid bootstrap-reboot bootstrap-utilities).each do |name|
16
+ # Compass treats non-partials as targets to copy into the main project, so make them partials.
17
+ # Also move them up a level to clearly indicate entry points.
18
+ from = "#{save_to}/#{name}.scss"
19
+ to = "#{save_to}/../_#{name}.scss"
20
+ FileUtils.mv from, to
21
+ # As we moved the files, adjust imports accordingly.
22
+ File.write to, File.read(to).gsub(/ "/, ' "bootstrap/')
23
+ end
24
+ end
25
+ end
26
+ end
data/tasks/updater.rb ADDED
@@ -0,0 +1,67 @@
1
+ # coding: utf-8
2
+
3
+ require 'open-uri'
4
+ require 'json'
5
+ require 'strscan'
6
+ require 'forwardable'
7
+ require 'term/ansicolor'
8
+ require 'fileutils'
9
+
10
+ require_relative 'updater/scss'
11
+ require_relative 'updater/js'
12
+ require_relative 'updater/logger'
13
+ require_relative 'updater/network'
14
+
15
+ class Updater
16
+ extend Forwardable
17
+ include Network
18
+ include Js
19
+ include Scss
20
+
21
+ def initialize(repo: 'twbs/bootstrap', branch: 'main', save_to: {}, cache_path: 'tmp/bootstrap-cache')
22
+ @logger = Logger.new
23
+ @repo = repo
24
+ @branch = branch || 'main'
25
+ @branch_sha = get_branch_sha
26
+ @cache_path = cache_path
27
+ @repo_url = "https://github.com/#@repo"
28
+ @save_to = {
29
+ js: 'assets/javascripts/bootstrap',
30
+ scss: 'assets/stylesheets/bootstrap'}.merge(save_to)
31
+ end
32
+
33
+ def_delegators :@logger, :log, :log_status, :log_processing, :log_transform, :log_file_info, :log_processed, :log_http_get_file, :log_http_get_files, :silence_log
34
+
35
+ def update_bootstrap
36
+ log_status 'Updating Bootstrap'
37
+ puts " repo : #@repo_url"
38
+ puts " branch : #@branch_sha #@repo_url/tree/#@branch"
39
+ puts " save to: #{@save_to.to_json}"
40
+ puts " twbs cache: #{@cache_path}"
41
+ puts '-' * 60
42
+
43
+ FileUtils.rm_rf('assets')
44
+ @save_to.each { |_, v| FileUtils.mkdir_p(v) }
45
+
46
+ update_scss_assets
47
+ update_javascript_assets
48
+ store_version
49
+ end
50
+
51
+ def save_file(path, content, mode='w')
52
+ dir = File.dirname(path)
53
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
54
+ File.open(path, mode) { |file| file.write(content) }
55
+ end
56
+
57
+ def upstream_version
58
+ @upstream_version ||= get_json(file_url 'package.json')['version']
59
+ end
60
+
61
+ # Update version.rb file with BOOTSTRAP_SHA
62
+ def store_version
63
+ path = 'lib/bootstrap/version.rb'
64
+ content = File.read(path).sub(/BOOTSTRAP_SHA\s*=\s*['"][^'"]*['"]/, "BOOTSTRAP_SHA = '#@branch_sha'")
65
+ File.open(path, 'w') { |f| f.write(content) }
66
+ end
67
+ end
@@ -0,0 +1,3 @@
1
+ == README
2
+
3
+ This is a minimal Rails app for testing
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
File without changes
@@ -0,0 +1,8 @@
1
+ //= require popper.js
2
+ //= require bootstrap-sprockets
3
+
4
+ document.addEventListener('DOMContentLoaded', () => {
5
+ for (const tooltipTriggerEl of document.querySelectorAll('[data-bs-toggle="tooltip"]')) {
6
+ new bootstrap.Tooltip(tooltipTriggerEl)
7
+ }
8
+ });
@@ -0,0 +1 @@
1
+ Chrome >= 25
@@ -0,0 +1,4 @@
1
+ @import 'bootstrap'
2
+
3
+ .test-mixin
4
+ +make-container
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,4 @@
1
+ class PagesController < ApplicationController
2
+ def root
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>bootstrap Dummy App</title>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <%= stylesheet_link_tag 'application', media: "all", 'data-turbolinks-track' => true %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+
11
+ <body>
12
+ <%= yield %>
13
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
14
+ </body>
15
+
16
+ </html>
@@ -0,0 +1,89 @@
1
+ <nav class="navbar navbar-expand-lg navbar-light bg-light">
2
+ <div class="container-fluid">
3
+ <a class="navbar-brand" href="#">Navbar</a>
4
+ <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
5
+ aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
6
+ <span class="navbar-toggler-icon"></span>
7
+ </button>
8
+ <div class="collapse navbar-collapse" id="navbarSupportedContent">
9
+ <ul class="navbar-nav me-auto mb-2 mb-lg-0">
10
+ <li class="nav-item">
11
+ <a class="nav-link active" aria-current="page" href="#">Home</a>
12
+ </li>
13
+ <li class="nav-item">
14
+ <a class="nav-link" href="#">Link</a>
15
+ </li>
16
+ <li class="nav-item dropdown">
17
+ <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown"
18
+ aria-expanded="false">
19
+ Dropdown
20
+ </a>
21
+ <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
22
+ <li><a class="dropdown-item" href="#">Action</a></li>
23
+ <li><a class="dropdown-item" href="#">Another action</a></li>
24
+ <li>
25
+ <hr class="dropdown-divider">
26
+ </li>
27
+ <li><a class="dropdown-item" href="#">Something else here</a></li>
28
+ </ul>
29
+ </li>
30
+ <li class="nav-item">
31
+ <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
32
+ </li>
33
+ </ul>
34
+ <form class="d-flex">
35
+ <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
36
+ <button class="btn btn-outline-success" type="submit">Search</button>
37
+ </form>
38
+ </div>
39
+ </div>
40
+ </nav>
41
+
42
+ <div class="container">
43
+ <div class="row">
44
+ <div class="card" style="width: 18rem;">
45
+ <div class="card-body">
46
+ <h5 class="card-title">Card title</h5>
47
+ <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
48
+ content.</p>
49
+ <a href="#" class="btn btn-primary">Go somewhere</a>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ <div class="row">
54
+ <div class="col-sm">
55
+ <div class="card" style="width: 18rem;">
56
+ <ul class="list-group list-group-flush">
57
+ <li class="list-group-item">An item</li>
58
+ <li class="list-group-item">A second item</li>
59
+ <li class="list-group-item">A third item</li>
60
+ </ul>
61
+ </div>
62
+ </div>
63
+ <div class="col-sm">
64
+ <div class="btn-group" role="group" aria-label="Basic mixed styles example">
65
+ <button type="button" class="btn btn-danger">Left</button>
66
+ <button type="button" class="btn btn-warning">Middle</button>
67
+ <button type="button" class="btn btn-success">Right</button>
68
+ </div>
69
+ </div>
70
+ <div class="col-sm">
71
+ <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top"
72
+ title="Tooltip on top">
73
+ Tooltip on top
74
+ </button>
75
+ <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="right"
76
+ title="Tooltip on right">
77
+ Tooltip on right
78
+ </button>
79
+ <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="bottom"
80
+ title="Tooltip on bottom">
81
+ Tooltip on bottom
82
+ </button>
83
+ <button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="left"
84
+ title="Tooltip on left">
85
+ Tooltip on left
86
+ </button>
87
+ </div>
88
+ </div>
89
+ </div>
@@ -0,0 +1,32 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails'
4
+
5
+ %w(
6
+ action_controller
7
+ action_view
8
+ sprockets
9
+ ).each do |framework|
10
+ require "#{framework}/railtie"
11
+ end
12
+
13
+ require 'autoprefixer-rails'
14
+ require 'uglifier'
15
+ require 'bootstrap'
16
+
17
+ module Dummy
18
+ class Application < Rails::Application
19
+ config.assets.enabled = true if config.assets.respond_to?(:enabled)
20
+ if Rails::VERSION::MAJOR > 4
21
+ # Rails 4 precompiles application.css|js by default, but future version of Rails do not.
22
+ config.assets.precompile += %w( application.css application.js )
23
+ end
24
+ config.to_prepare do
25
+ if ENV['VERBOSE']
26
+ STDERR.puts "Loaded Rails #{Rails::VERSION::STRING}, Sprockets #{Sprockets::VERSION}",
27
+ "Asset paths: #{Rails.application.config.assets.paths}"
28
+ end
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!
@@ -0,0 +1,23 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Print deprecation notices to the Rails logger.
17
+ config.active_support.deprecation = :log
18
+
19
+ # Debug mode disables concatenation and preprocessing of assets.
20
+ # This option may cause significant delays in view rendering with a large
21
+ # number of complex assets.
22
+ config.assets.debug = true
23
+ end
@@ -0,0 +1,82 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both thread web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ if config.respond_to?(:serve_static_files)
24
+ # rails >= 4.2
25
+ config.serve_static_files = true
26
+ elsif config.respond_to?(:serve_static_assets)
27
+ # rails < 4.2
28
+ config.serve_static_assets = true
29
+ end
30
+
31
+ # Compress JavaScripts and CSS.
32
+ config.assets.js_compressor = :uglifier
33
+ # config.assets.css_compressor = :sass
34
+
35
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
36
+ config.assets.compile = false
37
+
38
+ # Generate digests for assets URLs.
39
+ config.assets.digest = true
40
+
41
+ # Version of your assets, change this if you want to expire all your assets.
42
+ config.assets.version = '1.0'
43
+
44
+ # Specifies the header that your server uses for sending files.
45
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
46
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
47
+
48
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
49
+ # config.force_ssl = true
50
+
51
+ # Set to :debug to see everything in the log.
52
+ config.log_level = :info
53
+
54
+ # Prepend all log lines with the following tags.
55
+ # config.log_tags = [ :subdomain, :uuid ]
56
+
57
+ # Use a different logger for distributed setups.
58
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
59
+
60
+ # Use a different cache store in production.
61
+ # config.cache_store = :mem_cache_store
62
+
63
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
64
+ # config.action_controller.asset_host = "http://assets.example.com"
65
+
66
+ # Precompile additional assets.
67
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
68
+ # config.assets.precompile += %w( search.js )
69
+
70
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
71
+ # the I18n.default_locale when a translation can not be found).
72
+ config.i18n.fallbacks = true
73
+
74
+ # Send deprecation notices to registered listeners.
75
+ config.active_support.deprecation = :notify
76
+
77
+ # Disable automatic flushing of the log to improve performance.
78
+ # config.autoflush_log = false
79
+
80
+ # Use default logging formatter so that PID and timestamp are not suppressed.
81
+ config.log_formatter = ::Logger::Formatter.new
82
+ end