- Getting the lab project
- Fork our skeleton project repository into your own Github account (Optional)
- Clone the repository locally
- Create a branch for your work today
- Add a note in the README file
- Stage the changed README file (check
git statusto see what is staged) - Unstage the README file (check
git status) - Stage the file (again)
- Commit the change
- View the commit log
- Push to your repository (Optional, only if you did step 1)
- Setting up Grunt
- Create a git branch for setting up Grunt
- Create a
package.jsonfile for our Node modules- Make sure to add
gruntas a dependency
- Make sure to add
- Install Node dependencies
- Install the Grunt command line interface globally with
npm install -g grunt-cli - Create a
Gruntfile.jsfor the tasks and config - Add the
grunt-contrib-copyplugin - Edit the
copytask config to copy all JS files and assets to adistdirectory- Test your new task by running
grunt copy - Investigate the
cwdandexpandoptions to ensure the files are copied to the correct directories - Create a
defaultGrunt task that just runs thecopytask for now
- Test your new task by running
- Stage and commit your changes
- Make sure the
node_modulesdirectory is not committed to Git! - Make sure the
distdirectory is not committed to Git!
- Make sure the
- Merge this branch back into your branch from Task #1
- View the commit log on your original branch
- If you have extra time, add a
cleantask to remove thedistdirectory before doing the copy for thedefaulttask
- Preventing bugs with JSLint/Hint
- Add JSHint to our node modules and re-install dependencies
- Try using this shortcut on the command line:
npm install grunt-contrib-jshint --save-dev
- Try using this shortcut on the command line:
- Create a
.jshintrcfile in the project root, add some jshint options there- Be sure to at least add these:
{ "eqeqeq": true, "indent": 4, "lastsemic": false, "quotmark": true, "strict": true, "undef": true, }
- Be sure to at least add these:
- Add a
jshintconfig block to your Gruntfile - Run
grunt jshintand see what you get- Consider what else you may need to add to the
.jshintrcfile - Fix some of the jshint errors and try to get it to pass the jshint task cleanly
- Consider what else you may need to add to the
- Add the
jshinttask to the list ofdefaulttasks - Stage and commit your work
- Minifying code with UglifyJS
- Add the
grunt-cotnrib-uglifyplugin to your application - Add an
uglifytask to your Gruntfile- Make it create a single file from all of your application JavaScript
- Make sure to not include any vendor files, and to make
app.jscome first!
- Run your uglify task to confirm it works
- If you have time, Add the
sourceMapoption and make it create the source map file in thedist/js/directory- Notice anything off about your sourcemap? Think about where the files are being "sourced" from and written to.
- Add this task to your
defaulttask - Stage and commit your work
- Mange front end dependencies with Bower
- Install bower globally via
npm install -g bower - Add a
bower.jsonfile to the project root- Add a
nameandversion, then an emptydependenciesobject in that JSON file
- Add a
- Create a
.bowerrcfile also in the project root- Set the install directory for bower in this file:
{ "directory": "src/js/vendor" }
- Set the install directory for bower in this file:
- Install jquery and underscore via Bower
- You can either add them manually to the bower.json file, then run
bower installfrom the command line... - ... or you can run
bower install jquery --save-devfrom the command line (and similar for underscore)
- You can either add them manually to the bower.json file, then run
- Update the
index.htmlfile to point to the correct location for these files- If you have extra time, consider how you might copy these files into the
dist/directory and reference them there.
- If you have extra time, consider how you might copy these files into the
- Stage and commit your work
- Make sure you don't commit
vendorfiles!
- Make sure you don't commit
- Setting up a QUnit test suite
- Investigate the
beer-model.htmlfile in thespecs/directory - Create the test spec JavaScript file called
beer.model.spec.jsin the same directory - Write a test for the basic Beer object model
- Make sure the
Beerobject exists on the proper namespace (anokcheck onwindow.beerApp.Beer) - Make sure the deafult options are used if none are passed in (create a
Beerwith no options and check various properties) - Make sure the correct options are used if they are passed in (create a
Beerwith custom options and check various properties) - Make sure the
toStringmethod works correctly
- Make sure the
- Check the test results in the browser by loading that html file
- Stage and commit your changes
- Create a new test file for the
indexViewModel
- Create a new test file for the
indexViewModelinspecs/(maybe calledindexViewModel.html)- You can use the
beer-model.htmlfile as a basis - Be sure to include the proper source file!
- Be sure to create (and reference) a new JavaScript file for the tests! (maybe called
indexViewModel.spec.js)
- You can use the
- Create a module for some basic tests surrounding creating an IndexViewModel (maybe called "IndexViewModel Creation")
- Ensure that the
IndexViewModelobject exists on the namespace - Ensure that an IndexViewModel object can be created
- Ensure that the created view model has a beers array of length 0 and a favorites array of length 0
- Ensure that the
- Create a module for the "favorites" functionality
- Ensure that adding a favorites increases the size of the array
- Ensure that removing a favorite removes the correct entry from the array (What assertion should you use?)
- Check all of the results as you go
- Stage and commit your changes
- Set up test automation in Grunt
- Install the
grunt-contrib-qunitplugin via npm (Make sure it gets added topackage.json!) - Configure the
qunitGrunt task to run all test files - Run
grunt qunitto test the results - Add the
qunittask to thedefaulttask - Stage and commit your changes
- Styling the Beer App
- Add the
grunt-sassplugin - Use variables to add some colors and positions to the elements using the
src/sass/screen.scssfile - Using style nesting to override the paragraph styles in the footer
- Use a loop to style different beers differently (perhaps odd & even rows?)
- Play with mixins to see what you can do!