Skip to content

Commit

Permalink
basic project setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Zdrazil committed Feb 16, 2014
1 parent a49c2b3 commit 1a3da17
Show file tree
Hide file tree
Showing 15 changed files with 626 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "vendor",
"json": "bower.json"
}
48 changes: 48 additions & 0 deletions src/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"globals": [
"REQUIRE_CONFIG",
"require",
"define",
"describe",
"beforeEach",
"afterEach",
"module",
"inject",
"spyOn",
"expect",
"it"
],

"browser": true,
"worker": true,

"bitwise": false,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"forin": true,
"immed": true,
"indent": 4,
"latedef": true,
"maxcomplexity": 10,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"regexp": false,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"white": false,
"maxparams": 7,
"maxdepth": 4,
"maxlen": 120,
"eqnull": true,

"evil": false,
"onecase": true,
"devel": true
}
164 changes: 164 additions & 0 deletions src/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
module.exports = function (grunt) {
'use strict';

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

// SASS minification settings
sass: {
dist: {
unixNewlines: true,
files: [{
cwd: 'scss',
src: ['*.scss'],
dest: '../www/css',
ext: '.css'
}]
}
},

// move requirejs to the appropriate location
uglify: {
dev: {
options: {
mangle: false,
},
files: {
'../www/js/require.js': 'vendor/requirejs/require.js'
}
}
},
// unit testing
karma: {
// perform a single run
unit: {
autoWatch: false,
configFile: 'karma.conf.js',
singleRun : true,
browsers : ['PhantomJS']
}
// uncomment only if you're the kind of developer to use watch tasks
/* ,
watch: { // used in grunt watch context
background: true,
configFile: 'karma.conf.js',
singleRun: false,
browsers : ['PhantomJS']
}*/
},

// javascript file minification settings
requirejs: {
configCompile: {
options: {
// Note: all paths are relative to build.js
baseUrl: './',
name: 'app/requireConfigSettings', // Input script (.js extension inferred)
out: '../www/js/requireConfigSettings.js', // Path for combined script output

// fileExclusionRegExp: /.svn/, // Ignore all files matching this pattern
//useStrict: true,

optimize: 'none'
}
},
dev: {
options: {
baseUrl: './',
name: 'app/bootstrap',
out: '../www/js/bootstrap.js',
optimize: 'none'
}
},
compile: {
options: {//grunt.file.readJSON('buildMain.json')
// Note: all paths are relative to build.js
baseUrl: './',
name: 'app/bootstrap', // Input script (.js extension inferred)
out: '../www/js/bootstrap.js', // Path for combined script output

//fileExclusionRegExp: /.svn/, // Ignore all files matching this pattern
//useStrict: true,

mainConfigFile: 'app/requireConfigSettings.js',

optimize: 'uglify',

uglify: {
toplevel: false,
beautify: false,
ascii_only: true
},

/**
* Override any paths here that can't be minified, such as the CDN google maps reference
* if it's included in the application
*
* use the "empty:" string to tell the minifier to ignore it- the : is not a typo
*/
// paths: {
// googlemaps: 'empty:',
// },

// annotate any angular files whose injection requirements can be inferred
// doesn't work if you pass in a name reference rather than an anonymous function
onBuildRead: function (moduleName, path, contents) {
return require('ng-annotate')(contents, {add: true}).src;
}
}
}
},
plato: {
main: {
options: {
jshint: grunt.file.readJSON('.jshintrc')
},
files: {
'../build-reports/plato': ['app/**/*.js']
}
}
},
jsdoc : {
dist : {
src: ['app/**/*.js'],
options: {
destination: '../build-reports/jsdocs'
}
}
}
});

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-plato');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-jsdoc');

// Default task(s).
grunt.registerTask('default', ['karma:unit']);

// sass tasks
grunt.registerTask('build:sass', ['sass']);

// js tasks
grunt.registerTask('build:js:dev', ['requirejs:configCompile', 'requirejs:dev']);
grunt.registerTask('build:js', ['requirejs:configCompile', 'requirejs:compile']);

grunt.registerTask('build:dev', [
'uglify',
'karma:unit',
'build:sass',
'build:js:dev'
]);

grunt.registerTask('build', [
'uglify',
'karma:unit',
'plato',
'jsdocs',
'build:sass',
'build:js'
]);
};
15 changes: 15 additions & 0 deletions src/app/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* bootstraps angular onto the window.document node
* NOTE: the ng-app attribute should not be on the index.html when using ng.bootstrap
*/
define([
'angular',
'app/Application',
// include module index files here
'app/modules/home/index'
//
], function (ng) {
'use strict';

ng.bootstrap(document, ['app']);
});
18 changes: 18 additions & 0 deletions src/app/modules/home/HomeController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
define(/** @lends HomeController */function(require) {
'use strict';

var homeModule = require('./HomeModule');

homeModule.controller(
'HomeController',
/**
* @constructor
* @param {$log} Angular's wrapper for window.console.log
* @param {$alert} Angular's wrapper for window.alert
*/
function($log, $alert) {
$log($alert);
}
);

});
2 changes: 2 additions & 0 deletions src/app/modules/home/HomeControllerTemplate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Home controller template.</h1>
<p>No real angular work here, just demonstrating that the router works</p>
35 changes: 35 additions & 0 deletions src/app/modules/home/HomeModule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @fileOverview Module files are containers for directives and controllers that are specific to sections or components
* of the application.
* Routes can also be defined in module files, if the module represents a top-level view that should
* integrate with ng-view for handling route changes.
*/

define(/** @lends HomeModule */function(require) {
'use strict';

var ng = require('angular');

/**
* @requires HomeController
*/
var homeControllerTemplate = require('text!./HomeControllerTemplate.html');
require('./HomeController');

/**
* @namespace {ng.Module} HomeModule
*/
var homeModule = ng.module('app.home', [
'ngRoute'
]);

homeModule.config(function($routeProvider) {
$routeProvider
.when('/', {
template: homeControllerTemplate,
controller: 'HomeController'
});
});

return homeModule;
});
5 changes: 5 additions & 0 deletions src/app/modules/home/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
define(function(require) {
'use strict';

require('./HomeController');
});
35 changes: 35 additions & 0 deletions src/app/requireConfigSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(function(ns) {
'use strict';

// If window is a variable, assign the config to it
// Especially helpful for not duplicating the config in the karma test runner, but it may not be available if pulled
// in via the minification configuration
var namespace = ns || {};

namespace.REQUIRE_CONFIG = {
// alias paths for library modules
paths: {
angular: '../lvendor/angular/angular',
'angular-route': '../lvendor/angular-route/angular-route',
'angular-bindonce': '../lvendor/angular-bindonce/bindonce',
},

// shim settings for files that are not AMD compliant
// this tells require.js how to handle non-modular files
angular: {
exports: 'angular'/*,
// only use jquery if you have an absolute need to do so
// don't forget to add it to bower and the paths config above
deps: ['jquery'] */
},
'angular-route': {
deps: ['angular']
},
'angular-bindonce': {
deps: ['angular']
},
};

return namespace.ns;

})(window);
18 changes: 18 additions & 0 deletions src/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "Angular-Require starter",
"version": "0.0.1",
"ignore": [
"**/.*",
"node_modules",
"components"
],
"private": true,
"dependencies": {
"angular": "latest",
"requirejs": "latest",
"requirejs-text": "latest",
"angular-mocks": "latest",
"angular-route": "latest",
"angular-bindonce": "latest",
}
}
Loading

0 comments on commit 1a3da17

Please sign in to comment.