In this recipe, we will see how to have a fine-grained view of the changes between Bootstrap 4 versions, using Bower. We will first install Bower, and then utilize Git to make comparisons.
To begin with, all we need to do is make a new project on Cloud9 IDE, without cloning a repository.
- Install
bower
usingnpm
:
npm install -g bower
- Verify the
bower
installation:
which bower && bower -v
- Install Bootstrap 4 alpha 5 (this is not a typo!):
bower install bootstrap#v4.0.0-alpha.5
- See the list of the installed dependencies:
bower list
The preceding command will print out the status of your project's dependencies, including the available update to the currently installed Bootstrap 4 alpha 5.
- Initialize
git
in root:
cd && cd workspace; git init
- Stage the files into git's staging area:
git add --all
- Commit the changes with a message:
git commit -m “Add B4, alpha 5”
- Upgrade Bootstrap 4 to alpha 6 with
bower
:
bower install bootstrap#v4.0.0-alpha.6
Note
To install this update, Windows users will have to use the command prompt (rather than Git Bash for Windows). When prompted for answer, type "2" and then press ENTER.
- Now, using
git diff
, we have at our fingertips the full view of changes that happened between alpha 5 and alpha 6 versions of Bootstrap 4. However, it is not feasible to simply use a blanketgit diff
command because too many changes are made to too many files between each version. A much better strategy is to use thegit diff --stat
, with the--stat
flag giving us a nice overall idea of the changes, as well as which files had the most changes and which had the least. The following screenshot lists only the beginning of the output of thegit diff --stat
command, and does not include all the files affected, but it gives us a nice visual overview of changes made between alpha versions 5 and 6:
Note
For Windows users, before listing the result of the git diff --stat
command, Windows command prompt will throw a bunch of errors--just use the Page Down button to move past them.
- Now we can inspect only the files that we are interested in, for example, the following command:
git diff bower_components/bootstrap/scss/_alert.scss
The preceding command will show us the changes made only in the _alert.scss
partial, between Bootstrap 4 Alpha 5 and Alpha 6 versions. In the following screenshot, we can see one of the changes made to this file:
- With this approach, it is also really simple to track the changes to the
_alert.scss
file in the previous versions of Bootstrap 4 alpha. For example, we can downgrade our Bootstrap 4 installation with the help of Bower, and then repeat ourgit diff
for the_alert.scss
file only, by running the following commands:
bower install bootstrap#4.0.0-alpha.4 git diff bower_components/bootstrap/scss/_alert.scss
With this recipe, we are able to have complete, fine-grained control of observing the changes made to the framework through its versions. This is an amazing approach to understand the changes that occurred to specific components between different versions of the framework. It can help us understand why bugs occurred in our code, avoid pitfalls when working with legacy code, and learn the approaches taken by the Bootstrap contributors and how to better work with Sass in Bootstrap.