Package Managers are really cool, but sometimes you need to download files for yourself.

Bootstrap for example lets you customize variables, but you really need to download the source files before you can customize anything.

So how do you maintain sanity of a package manager but still download the source files to your project?

SCRIPTS TO THE RESCUE

create a rakefile.rb

namespace :fetch do
  desc "fetch bootstrap scss files"
  task :bootstrap do
    current_bootstrap_version = "4.4.1"
    target = "_sass/bootstrap/"
    `rm -rf #{target}`
    `mkdir #{target}`
    `curl -LkSs https://github.com/twbs/bootstrap/archive/v#{current_bootstrap_version}.tar.gz | tar xz`
    `mv -fv ./bootstrap-#{current_bootstrap_version}/scss/* ./#{target}`
    `rm -rf bootstrap-#{current_bootstrap_version}/`
  end
end

Note: This script will absolutely destroy your files, so make sure you’re using GIT and keeping track of yourself.{.alert.alert-warning}

You can run rake fetch:bootstrap and get a fresh folder of SCSS files

First we clarify VARIABLES for the current version of bootstrap you want to download.

As a sanity check this should be accessible at github.com/twbs/bootstrap/releases/tag/v{VERSION}

For example 4.4.1 is https://github.com/twbs/bootstrap/releases/tag/v4.4.1

Lets look Line-By-Line

  1. Set the version number: current_bootstrap_version = "4.4.1"
  2. Set your Target directory (where do you want this to live?): target = "_sass/bootstrap/"
  3. DELETE old files: rm -rf #{target}
  4. Create new Target directory: mkdir #{target}
  5. Download and untar the artifact: curl -LkSs https://github.com/twbs/bootstrap/archive/v#{current_bootstrap_version}.tar.gz | tar xz
  6. Move all the files: mv -fv ./bootstrap-#{current_bootstrap_version}/scss/* ./#{target}
  7. Cleanup the recently downloaded artifact: rm -rf bootstrap-#{current_bootstrap_version}/

When you’re done, you should have a fresh