class TailwindCss::Utils::Bump
@see ruby-doc.org/core-2.7.1/Regexp.html#class-Regexp-label-Capturing capture groups
Constants
- GSUB_REGEX
- NPM_VERSION_REGEX
- RUBY_VERSION_REGEX
- VERSION_LINE
- VERSION_REGEX
Public Instance Methods
bump_to_zero(type, groups)
click to toggle source
# File lib/bridgetown-plugin-tailwindcss/utils.rb, line 88 def bump_to_zero(type, groups) return if type == :patch groups[:patch] = "0" return if type == :minor groups[:minor] = "0" end
bump_version(type, version: VERSION)
click to toggle source
# File lib/bridgetown-plugin-tailwindcss/utils.rb, line 37 def bump_version(type, version: VERSION) say(version_change(type, version: version), :red) version_files.each do |file| match = GSUB_REGEX.match(File.read(file)) gsub_string = "#{match[:version]}#{to_version(type, version: version)}" gsub_file(file, GSUB_REGEX, gsub_string) end end
bump_version_to_string(string)
click to toggle source
# File lib/bridgetown-plugin-tailwindcss/utils.rb, line 27 def bump_version_to_string(string) say("Bumping from #{VERSION} to #{string}", :red) match = GSUB_REGEX.match(File.read(file)) gsub_string = "#{match[:version]}#{string}" version_files.each do |file| gsub_file(file, GSUB_REGEX, gsub_string) end end
current_version()
click to toggle source
# File lib/bridgetown-plugin-tailwindcss/utils.rb, line 23 def current_version VERSION end
gsub_match(file)
click to toggle source
# File lib/bridgetown-plugin-tailwindcss/utils.rb, line 51 def gsub_match(file) GSUB_REGEX.match(File.read(file)) end
to_version(type, version: nil)
click to toggle source
ef version_replacement
match = GSUB_REGEX.match(File.readlines
end
# File lib/bridgetown-plugin-tailwindcss/utils.rb, line 66 def to_version(type, version: nil) from = version match = VERSION_REGEX.match(from) groups = { major: match[:major], minor: match[:minor], patch: match[:patch], } unless groups.key?(type) raise "\nYou gave #{type} but the only accepted types are #{groups.keys}" end groups[type] = (groups[type].to_i + 1).to_s bump_to_zero(type, groups) "#{groups[:major]}.#{groups[:minor]}.#{groups[:patch]}" end
version_change(type, version: nil)
click to toggle source
# File lib/bridgetown-plugin-tailwindcss/utils.rb, line 98 def version_change(type, version: nil) "Bumping from #{version} to #{to_version(type, version: version)}" end
version_files()
click to toggle source
# File lib/bridgetown-plugin-tailwindcss/utils.rb, line 55 def version_files package_json = File.expand_path("package.json") version_file = File.expand_path(File.join(__dir__, "version.rb")) [package_json, version_file] end