From 2d885cde02ffd6a1f31966548060fead44d399ee Mon Sep 17 00:00:00 2001 From: atomicpages Date: Mon, 7 Jul 2014 15:52:09 -0700 Subject: [PATCH] 2.0.0-b10 Changed all of the shell scripts to ruby scripts. Still ned to finish the upgrade script and tests need to e run on windows still --- .gitattributes | 2 + .gitignore | 23 +------ bin/assets/helper.rb | 62 ++++++++++++++++++ bin/setup.rb | 35 ++++++++++ bin/setup.sh | 49 -------------- bin/theme_setup.rb | 40 ++++++++++++ bin/theme_setup.sh | 128 ------------------------------------- bin/update.rb | 52 +++++++++++++++ bin/update.sh | 49 -------------- bin/upgrade.rb | 58 +++++++++++++++++ bower.json | 2 +- skeleton/core/_config.scss | 2 +- 12 files changed, 252 insertions(+), 250 deletions(-) create mode 100644 .gitattributes create mode 100644 bin/assets/helper.rb create mode 100755 bin/setup.rb delete mode 100755 bin/setup.sh create mode 100755 bin/theme_setup.rb delete mode 100755 bin/theme_setup.sh create mode 100755 bin/update.rb delete mode 100755 bin/update.sh create mode 100755 bin/upgrade.rb diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore index 1ea1763..197ca7d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,5 @@ -*.gem -*.rbc -.bundle -.config .sass-cache -flavors/*/css *.config.scss -skeleton.scss -skeleton.css +skeleton.* skeleton_template.css *.html -coverage -InstalledFiles -lib/bundler/man -pkg -rdoc -spec/reports -test/tmp -test/version_tmp -tmp -TODO.md - -# YARD artifacts -.yardoc -_yardoc -doc/ diff --git a/bin/assets/helper.rb b/bin/assets/helper.rb new file mode 100644 index 0000000..bada977 --- /dev/null +++ b/bin/assets/helper.rb @@ -0,0 +1,62 @@ +module Helper + + def isValidName(name) + if name !~ /[-a-zA-Z0-9_]+/i + return false + end + + return true + end + + def yesno(question) + puts question + answer = gets.chomp + while answer !~ /y(es)?|n(o)?/i do + puts "Invalid input. #{question} [y/n]" + answer = gets.chomp + yesno(question) + end + + if answer =~ /y(es)/i + return true + end + + return false + end + + def nfqr(question, regex, errorMsg = "Invalid input. #{question}", isValid = nil) + puts isValid != 0 ? question : errorMsg + reply = gets.chomp + + if reply =~ regex + return nfqr(question, regex, errorMsg, 0) + end + + return reply + end + + def cp(file, destination) + if !File.exists?(file) # fail quickly if not found + raise SystemCallError, "#{file} was not found or does not exist" + end + + dest = File.open(destination, "w") + + File.open(file, "r") do |f| + f.each_line do |line| + dest.puts(line) + end + end + + dest.close + end + + def gem_available?(name) + Gem::Specification.find_by_name(name) + rescue Gem::LoadError + return false + rescue + return Gem.available?(name) + end + +end diff --git a/bin/setup.rb b/bin/setup.rb new file mode 100755 index 0000000..3b732a5 --- /dev/null +++ b/bin/setup.rb @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby -w + +require_relative("assets/helper") + +BEGIN { + if Dir.pwd =~ /bin$/i + Dir.chdir("../") + end + puts "Setup utility working..." +} + +include Helper + +STDOUT.flush +name = Helper.nfqr("Please enter in the name of your project with no spaces or special characters other than - or _ and press [ENTER]", /[^\w\-]/, "Project name invalid, please try again and press [ENTER]") + +puts "Project name is #{name}" +puts "Renaming _MYconfig.scss to _#{name}.config.scss" +File.rename("_MYconfig.scss", "_#{name}.config.scss") + +puts "Renaming skeleton_template to skeleton" +if File.exists?("skeleton_template.scss") + File.rename("skeleton_template.scss", "skeleton.scss") +else + puts "skeleton_template.scss does not exist. Skipping..." +end + +puts "Adding user override to core/_config.scss" +file = File.open("skeleton/core/_config.scss", "a") +file.puts "@import \"../../_#{name}.config.scss\"" +file.close + +END { + puts "Setup utility is complete!" +} diff --git a/bin/setup.sh b/bin/setup.sh deleted file mode 100755 index 88c07ab..0000000 --- a/bin/setup.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh - -echo "Setup utility working..." -cwd=${PWD##*/} - -if [[ $cwd = "bin" ]]; then - cd ../ -fi - -echo "Please enter in the name of your project with no spaces or special characters other than - or _ and press [ENTER]" -read name -validated=0; - -case $name in - *\ * ) - let validated=0 - ;; - *) - echo "Project name saved" - let validated=1 - ;; -esac - -while [ $validated -ne 1 ]; do - echo "Project name invalid, please try again and press [ENTER]" - read name - case $name in - *\ * ) - let validated=0 - ;; - *) - echo "Project name saved" - let validated=1 - ;; - esac -done - -echo "Project name is ${name}" -echo "Renaming user config from _MYconfig.scss to _${name}.config.scss" -mv _MYconfig.scss _${name}.config.scss - -echo "Renaming skeleton_template to skeleton" -mv skeleton_template.scss skeleton.scss - -echo "Adding user override to core/_config.scss" -echo "@import \"../../_${name}.config.scss\"" >> skeleton/core/_config.scss - -echo "Setup complete!" -exit 0; diff --git a/bin/theme_setup.rb b/bin/theme_setup.rb new file mode 100755 index 0000000..eb1462a --- /dev/null +++ b/bin/theme_setup.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby -w + +require_relative("assets/helper") + +BEGIN { + if Dir.pwd =~ /bin$/i + Dir.chdir("../") + end + puts "Theme setup utility working..." +} + +include Helper + +STDOUT.flush +name = Helper.nfqr("Please enter in the name of your theme with no spaces or special characters other than - or _ and press [ENTER]", /[^\w\-]/, "Theme name invalid, please try again and press [ENTER]") +puts "Theme name is #{name}" + +if !Dir.exists?("skeleton/themes/#{name}") + Dir.mkdir("skeleton/themes/#{name}") +end + +# create files and folders +puts "Creating required files and folders..." +file = File.open("skeleton/themes/_loader.scss", "w") +file.puts("// #{name} theme created with love using Skeleton Sass theme setup script!") +file.puts("\n@import \"#{name}/vars\";") +file.puts("@import \"#{name}/base\";") +file.puts("@import \"sphenoid/skeleton\"; // Override manually if you wish to create your own grid") +puts "skeleton/themes/_loader.scss has been updated... moving on" + +if !Dir.exists?("skeleton/themes/#{name}/marrow") + Dir.mkdir("skeleton/themes/#{name}/marrow") +end + +Helper.cp("skeleton/themes/demo/_base.scss", "skeleton/themes/#{name}/_base.scss") +Helper.cp("skeleton/themes/demo/_vars.scss", "skeleton/themes/#{name}/_vars.scss") + +END { + puts "Theme setup complete!" +} diff --git a/bin/theme_setup.sh b/bin/theme_setup.sh deleted file mode 100755 index 93537c3..0000000 --- a/bin/theme_setup.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh - -echo "Theme Setup utility working..." -cwd=${PWD##*/} - -if [[ $cwd = "bin" ]]; then - cd ../ -fi - -echo "Please enter in the name of your theme with no spaces or special characters other than - or _ and press [ENTER]" -read name -validated=0; - -case $name in - *\ * ) - let validated=0 - ;; - *) - echo "Theme name saved" - let validated=1 - ;; -esac - -while [ $validated -ne 1 ]; do - echo "Theme name invalid, please try again and press [ENTER]" - read name - case $name in - *\ * ) - let validated=0 - ;; - *) - echo "Theme name saved" - let validated=1 - ;; - esac -done - -echo "Theme name is ${name}" - -echo "Creating required files and folders..." -echo "// ${name} theme created with love using Skeleton Sass theme setup script!" > skeleton/themes/_loader.scss -echo "@import \"${name}/vars\";" >> skeleton/themes/_loader.scss -echo "@import \"${name}/base\";" >> skeleton/themes/_loader.scss -echo "@import \"sphenoid/skeleton\"; // Override manually if you wish to create your own grid" >> skeleton/themes/_loader.scss -echo "skeleton/themes/_loader.scss has been updated... moving on" - - -mkdir -p skeleton/themes/${name}/marrow -cp skeleton/themes/demo/_base.scss skeleton/themes/${name} -cp skeleton/themes/demo/_vars.scss skeleton/themes/${name} - -echo "Use Bourbon? [y/n]" -read ans -valid=0 -bourbon=0 - -if [[ ($ans =~ "y") || ($ans =~ "Y") || ($ans =~ "n") || ($ans =~ "N") ]]; then - let valid=1 - if [[ ($ans =~ "n") || ($ans =~ "N") ]]; then - let bourbon=0 - else - let bourbon=1 - fi -else - let valid=0 -fi - -while [ $valid -ne 1 ]; do - echo "Invalid response, try again" - read ans - if [[ ($ans =~ "y") || ($ans =~ "Y") || ($ans =~ "n") || ($ans =~ "N") ]]; then - let valid=1 - if [[ ($ans =~ "n") || ($ans =~ "N") ]]; then - let bourbon=0 - else - let bourbon=1 - fi - else - let valid=0 - fi -done - -if [ $bourbon -eq 1 ]; then - # If gem doesn't exist then we don't need to bother - command -v gem >/dev/null 2>&1 || { - echo >&2 "Ruby Gems is not installed. Aborting." - echo "Note: your project setup to this point was successful" - exit 0 - } - # Does bourbon exist? No? Want to install it? Sure. Awesome! Let me install it for you. - command -v bourbon >/dev/null 2>&1 || { - echo >&2 "Bourbon is not currently installed. Install bourbon now? [y/n]" - echo "Note: you will be promoted to enter in your account password. This password is never saved. Ever." - read ans - let valid=0 - let bourbon=0 - if [[ ("$ans" = "y" || "$ans" = "n" || "$ans" = "Y" || "$ans" = "N") ]]; then - let valid=1 - echo "Installing bourbon..." - sudo gem install bourbon - else - let valid=0 - fi - - while [ $valid -ne 1 ]; do - echo "Invalid response, try again" - read ans - if [[ ("$ans" = "y" || "$ans" = "n" || "$ans" = "Y" || "$ans" = "N") ]]; then - let valid=1 - echo "Installing bourbon..." - sudo gem install bourbon - command -v bourbon >/dev/null 2>&1 || { - echo 2>&1 "Bourbon install failed. Aborting." - echo "Note: your project setup to this point was successful" - exit 0 - } - echo "Bourbon install was successful! Continuing..." - else - let valid=0 - fi - done - } - bourbon install --path=skeleton/themes/${name}/ - sed -i "" -e $'8 a\\\n'"@import \"bourbon/bourbon\";" skeleton/themes/${name}/_vars.scss -fi - -echo "Theme setup complete!" -exit 0 diff --git a/bin/update.rb b/bin/update.rb new file mode 100755 index 0000000..5e98060 --- /dev/null +++ b/bin/update.rb @@ -0,0 +1,52 @@ +#!/usr/bin/env ruby -w + +require_relative("assets/helper") +require 'rubygems' # if rubygems is not installed then we'll fail fast + +BEGIN { + if Dir.pwd =~ /bin$/i + Dir.chdir("../") + end + puts "Update utility working..." +} + +include Helper +STDOUT.flush + +if File.directory?("#{Dir.pwd}/.git") + if Helper.gem_available?('git') # assets the gem exists before we try to use it + require 'git' + g = Git.open(Dir.pwd) + if g.repo + if g.index.readable? + g.pull(g.repo, g.branch) + end + end + else + resp = Helper.yesno("Ruby git gem not found, install now? [y/n]") + if resp =~ /y(es)?/ + puts "Installing git gem..." + if RUBY_PLATFORM.downcase =~ /w(in)?32/i + `gem install git` + else + `sudo gem install git` + end + else + puts "Skipping git install..." + end + end +end + +if File.exists?(".bower.json") + resp = Helper.yesno("Bowers files found. Update with bower now? [y/n]") + if resp =~ /y(es)?/i + puts "Updating skeleton-sass" + `bower update skeleton-sass` + end +else + abort("No git repository or bower files were detected. Update manually...") +end + +END { + puts "Update complete!" +} diff --git a/bin/update.sh b/bin/update.sh deleted file mode 100755 index 1756fcb..0000000 --- a/bin/update.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh - -echo "Update utility working..." -cwd=${PWD##*/} - -if [[ $cwd="bin" ]]; then - cd ../ -fi - -echo "Update Skeleton Sass? [y/n]" -git=$(git rev-parse --is-inside-work-tree) - -read ans -valid=0 - -if [[ ("$ans" = "y" || "$ans" = "n" || "$ans" = "Y" || "$ans" = "N") ]]; then - let valid=1 -else - let valid=0 -fi - -while [ $valid -ne 1 ]; do - echo "Invalid response, try again" - read ans - if [[ ("$ans" = "y" || "$ans" = "n" || "$ans" = "Y" || "$ans" = "N") ]]; then - let valid=1 - else - let valid=0 - fi -done - -if [[ ("$ans" = "y" || "$ans" = "Y") ]]; then - if [[ $git="true" ]]; then - echo "Git repo found, pulling latest version from origin/master" - git pull origin/master - elif [[ -f .bower.config ]]; then - echo ".bower.config file detected, Skeleton Sass was installed using bower. Running bower update skeleton-sass" - cd ../ && bower update skeleton-sass - else - echo "Git repo not found. Bower files not found. Update manually" - exit 0 - fi - echo "Upgrade complete. Removing unneeded files" - rm _MYconfig.scss skeleton_template.scss -else - echo "Aborting" -fi - -exit 0 diff --git a/bin/upgrade.rb b/bin/upgrade.rb new file mode 100755 index 0000000..ba93218 --- /dev/null +++ b/bin/upgrade.rb @@ -0,0 +1,58 @@ +#!/usr/bin/env ruby -w + +require_relative("assets/helper") + +BEGIN { + if Dir.pwd =~ /bin$/i + Dir.chdir("../") + end + puts "Upgrade utility..." +} + +include Helper + +STDOUT.flush + +puts "Disclaimer: this utility it meant to aid in upgrading from Skeleton Sass 1.x to Skeleton Sass 2.x. If you have followed the wiki articles then please do not use this script without a clean installation of Skeleton Sass 2.x. We, AtomicPages LLC, are not responsible for any unforeseen events that arise by using this script. Please follow the prompts." + +resp = Helper.yesno("Did you add the contents from _vars.scss in Skeleton Sass 1.x to _MYconfig.scss in Skeleton Sass 2.x? [y/n]\nNote: If you ran the setup utility, your global configuration name might differ") + +if resp =~ /y(es)?/i + abort("Please copy the variables from _vars.scss and run the script again") +end + +puts "Converting variable names..." + +filename = "" +if RUBY_PLATFORM.downcase =~ /w(in)?32/i + filename = %x(dir /b *config.scss) +else + filename = %x(ls | grep config) +end + +if filename !~ /_+[\w-]*\.?conf(ig)?(uration)?\.scss/i + abort("Global config file in root not found. Please execute bin/upgrade within the skeleton-sass directory. Current working directory is #{Dir.pwd}") +end + +puts "Using #{filename}" + +variables = { + "backgroundColor" => "background-color", + "fontSize" => "font-size", + "fontFamily" => "font-family", + "fontColor" => "font-color", + "formFont" => "form-font", + "linkColor" => "link-color", + "linkHoverColor" => "link-hover-color", + "linkDecoration" => "link-decoration", + "headingFamily" => "heading-family", + "headingColor" => "heading-color", + "baseWidth" => "base-width", + "baseColWidth" => "base-col-width", + "baseGutterWidth" => "base-gutter-width", + "isFluid" => "is-fluid", + "baseColCount" => "base-col-count", + "tabletWidth" => "tablet-width", + "mobilePortraitWidth" => "mobile-portrait-width", + "mobileLandscapeWidth" => "mobile-landscape-width" +} diff --git a/bower.json b/bower.json index b4017b5..7a452a9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "skeleton-sass", - "version": "1.6.3", + "version": "2.0.0", "author": "Dennis Thompson", "homepage": "http://atomicpages.github.io/skeleton-sass/", "repository": { diff --git a/skeleton/core/_config.scss b/skeleton/core/_config.scss index 23ef37b..5379048 100644 --- a/skeleton/core/_config.scss +++ b/skeleton/core/_config.scss @@ -35,7 +35,7 @@ $is-fluid: false !global; // Change to true to enable the fluid grid $base-col-width: 40px !global; // The width of each columns $base-gutter-width: 20px !global; // The space between columns $base-col-count: 16 !global; // The number of columns -$base-width: if($is-fluid, 98%, ($base-col-width + $base-gutter-width) * $base-col-count); // Why not generate it for you? +$base-width: if($is-fluid, 98%, ($base-col-width + $base-gutter-width) * $base-col-count) !global; // Why not generate it for you? // BREAKPOINTS AND CONTAINER WIDTHS $tablet-width: 768px !global; // the tablet width media query