Class: Foundation::CLI::Generator
- Inherits:
-
Thor
- Object
- Thor
- Foundation::CLI::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/foundation/cli/generator.rb
Instance Method Summary collapse
Instance Method Details
#new(name) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/foundation/cli/generator.rb', line 116 def new(name) if [:libsass] install_dependencies(%w{git node bower grunt}) repo = "https://github.com/zurb/foundation-libsass-template.git" else install_dependencies(%w{git node bower compass}) repo = "https://github.com/zurb/foundation-compass-template.git" end say "Creating ./#{name}" empty_directory(name) run("git clone #{repo} #{name}", capture: true, verbose: false) inside(name) do say "Installing dependencies with bower..." run("bower install", capture: true, verbose: false) create_file "scss/_settings.scss", File.read("#{destination_root}/bower_components/foundation/scss/foundation/_settings.scss") run("git remote rm origin", capture: true, verbose: false) if [:libsass] run "npm install" run "grunt build" else if defined?(Bundler) Bundler.with_clean_env do run "compass compile" end end end end say "./#{name} was created" end |
#update ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/foundation/cli/generator.rb', line 150 def update unless which("bower") "Please install bower. Aborting." exit 1 end run "bower update" end |
#upgrade ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/foundation/cli/generator.rb', line 60 def upgrade install_dependencies(%w{git node bower compass}) if File.exists?(".bowerrc") begin json = JSON.parse(File.read(".bowerrc")) rescue JSON::ParserError json = {} end unless json.has_key?("directory") json["directory"] = "bower_components" end File.open(".bowerrc", "w") {|f| f.puts json.to_json} else create_file ".bowerrc" do {:directory=>"bower_components"}.to_json end end bower_directory = JSON.parse(File.read(".bowerrc"))["directory"] gsub_file "config.rb", /require [\"\']zurb-foundation[\"\']/ do |match| match = "add_import_path \"#{bower_directory}/foundation/scss\"" end unless File.exists?("bower.json") create_file "bower.json" do {:name => "foundation_project"}.to_json end end run "bower install zurb/bower-foundation --save" if defined?(Bundler) Bundler.with_clean_env do run("compass compile", capture: true, verbose: false) end else run("compass compile", capture: true, verbose: false) end say "\nFoundation 5 has been setup in your project.\n\nPlease update references to javascript files to look something like:\n\n<script src=\"\#{bower_directory}/foundation/js/foundation.min.js\"></script>\n\nTo update Foundation in the future, just run: foundation update\n\n EOS\nend\n" |
#version ⇒ Object
55 56 57 |
# File 'lib/foundation/cli/generator.rb', line 55 def version puts "v#{Foundation::CLI::VERSION}" end |