Last active
August 29, 2015 14:02
-
-
Save kristopherjohnson/f1d7e4d1c31ae3b0899e to your computer and use it in GitHub Desktop.
Set up yeoman and grunt to generate an AngularJS project and run it on OS X using Homebrew
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: Due to bugs in the Angular/Karma generators, the Karma runner may not work correctly when following the | |
// steps given in yeoman_angular.sh. If that's the case, compare the contents of your test/karma.conf.js with | |
// this version, and edit yours as needed. | |
// Karma configuration | |
// http://karma-runner.github.io/0.12/config/configuration-file.html | |
// Generated on 2014-06-05 using | |
// generator-karma 0.8.1 | |
module.exports = function(config) { | |
config.set({ | |
// enable / disable watching file and executing tests whenever any file changes | |
autoWatch: true, | |
// base path, that will be used to resolve files and exclude | |
basePath: '..', | |
// testing framework to use (jasmine/mocha/qunit/...) | |
frameworks: ['jasmine'], | |
// list of files / patterns to load in the browser | |
files: [ | |
'app/bower_components/angular/angular.js', | |
'app/bower_components/angular-resource/angular-resource.js', | |
'app/bower_components/angular-cookies/angular-cookies.js', | |
'app/bower_components/angular-sanitize/angular-sanitize.js', | |
'app/bower_components/angular-route/angular-route.js', | |
'app/bower_components/angular-mocks/angular-mocks.js', | |
'app/scripts/*.js', | |
'app/scripts/**/*.js', | |
'test/spec/**/*.js' | |
], | |
// list of files / patterns to exclude | |
exclude: [], | |
// web server port | |
port: 8080, | |
// Start these browsers, currently available: | |
// - Chrome | |
// - ChromeCanary | |
// - Firefox | |
// - Opera | |
// - Safari (only Mac) | |
// - PhantomJS | |
// - IE (only Windows) | |
browsers: [ | |
'PhantomJS' | |
], | |
// Which plugins to enable | |
plugins: [ | |
'karma-phantomjs-launcher', | |
'karma-jasmine' | |
], | |
// Continuous Integration mode | |
// if true, it capture browsers, run tests and exit | |
singleRun: false, | |
colors: true, | |
// level of logging | |
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG | |
logLevel: config.LOG_INFO, | |
// Uncomment the following lines if you are using grunt's server to run the tests | |
// proxies: { | |
// '/': 'http://localhost:9000/' | |
// }, | |
// URL root prevent conflicts with the site root | |
// urlRoot: '_karma_' | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First, set up Homebrew: http://brew.sh/ | |
# You have to have Xcode installed, and must run it at least once to install the command-line tools | |
# Install your own Ruby instead of using the system Ruby | |
# (so you can control version, install gems without sudo, etc.) | |
brew update | |
brew install rbenv | |
# Add these two lines to your .bashrc, then quit and restart Terminal | |
export RBENV_ROOT=/usr/local/var/rbenv | |
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi | |
# Install, globally set, and verify you have the Ruby you expect | |
brew install ruby-build | |
rbenv install 2.1.2 # or use 'rbenv install --list' to see which versions are available | |
rbenv global 2.1.2 | |
ruby --version | |
# Install Sass and Compass | |
gem update --system && gem install compass && gem install sass | |
# Set up node/npm | |
brew install node | |
# Install Grunt CLI and the Compass plugin | |
npm install -g grunt-cli | |
npm install -g grunt-contrib-compass | |
# Install Yeoman | |
npm install -g yo | |
# Install the AngularJS and Karma generators | |
npm install -g generator-angular | |
npm install -g generator-karma | |
# Create project directory and cd into it | |
mkdir my-project && cd my-project | |
# Run yo angular, optionally passing in app name. | |
# Answer "Y" for all questions, and select all optional modules. | |
yo angular foo # Will create AngularJS module "fooApp" | |
# Install grunt and grunt-karma in project | |
npm install grunt --save-dev | |
npm install grunt-karma --save-dev | |
# Build | |
grunt | |
# Run unit tests | |
# | |
# (Note: Due to bugs in the Angular/Karma generators, tests may not work. Compare the | |
# contents of your test/karma.conf.js to the sample provided here. Also, in your | |
# Gruntfile.js, you may need to change the path of karma.conf.js to 'test/karma.conf.js') | |
grunt test | |
# By default, unit tests will run in PhantomJS. To test in Chrome also, do the following: | |
npm install karma-chrome-launcher --save-dev | |
# Then, in karma.conf.js, add 'Chrome' to the browsers section, and add 'karma-clone-launcher' to the plugins section. | |
# Run server and show webpage | |
# Changes to source files will cause browser to update and tests to be re-run | |
grunt serve | |
# Build distribution (files created in /dist directory) | |
grunt build |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment