Commit a0b04376 authored by Evren Kutar's avatar Evren Kutar

grunt config for production

parent 32bec7c7
......@@ -6,14 +6,12 @@ module.exports = function (grunt) {
uglify: {
dist: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
mangle: false
},
//build: {
// src: 'src/<%= pkg.name %>.js',
// dest: 'build/<%= pkg.name %>.min.js'
//},
files: {
'dist/app.js': ['dist/app.js']
'dist/app.js': ['dist/app.js'],
'dist/bower_components/components.js': ['dist/bower_components/components.js']
}
}
},
......@@ -27,9 +25,6 @@ module.exports = function (grunt) {
}
}
},
jshint: {
all: ['Gruntfile.js', 'app/*.js', 'app/**/*.js']
},
karma: {
options: {
configFile: 'karma.conf.js'
......@@ -44,35 +39,59 @@ module.exports = function (grunt) {
}
},
html2js: {
dist: {
src: ['index.html', 'app/components/**/*.html'],
dest: 'tmp/templates.js'
options: {
rename: function (moduleName) {
return moduleName.replace('../app/', '');
}
},
prod: {
src: ['app/components/**/*.html'],
dest: 'dist/templates.js'
}
},
concat: {
options: {
separator: ';'
separator: '\n\n'
},
dist: {
src: ['app/**/*controller.js', 'app/**/*service.js', 'app/zetalib/**/*.js', 'app.js', 'app.routes.js'],
js: {
src: [
'app/app.js', 'app/app_routes.js', 'app/zetalib/**/*service.js', 'app/zetalib/general.js', 'app/zetalib/interceptors.js', 'app/components/**/*controller.js', 'app/components/**/*service.js'],
dest: 'dist/app.js'
},
components: {
src: ['app/bower_components/**/*.min.js'],
src: [
'app/bower_components/angular/angular.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-cookies/angular-cookies.js',
'app/bower_components/angular-resource/angular-resource.js',
'app/bower_components/angular-bootstrap/ui-bootstrap.js',
'app/bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
'app/bower_components/angular-sanitize/angular-sanitize.js',
'app/bower_components/tv4/tv4.js',
'app/bower_components/objectpath/lib/ObjectPath.js',
'app/bower_components/angular-schema-form/dist/schema-form.js',
'app/bower_components/angular-schema-form/dist/bootstrap-decorator.js',
'app/bower_components/angular-schema-form-datepicker/bootstrap-datepicker.js',
'app/bower_components/angular-gettext/dist/angular-gettext.js'
],
dest: 'dist/bower_components/components.js'
},
css: {
src: ['app/app.css', 'app/bower_components/**/**/*.css'],
dest: 'dist/app.css'
}
},
watch: {
dev: {
files: ['Gruntfile.js', 'app/**/*.js', 'index.html', 'app/components/**/*.html'],
tasks: ['jshint', 'karma:unit', 'html2js:dist', 'concat:dist', 'clean:temp'],
files: ['app/**/*.js', 'app/components/**/*.html'],
tasks: ['karma:unit', 'html2js:dist', 'concat:dist'],
options: {
atBegin: true
}
},
min: {
files: ['Gruntfile.js', 'app/**/*.js', 'index.html', 'app/components/**/*.html'],
tasks: ['jshint', 'karma:unit', 'html2js:dist', 'concat:dist', 'clean:temp', 'uglify:dist'],
files: ['app/**/*.js', 'index.html', 'app/components/**/*.html'],
tasks: ['karma:unit', 'html2js:dist', 'concat:dist', 'uglify:dist'],
options: {
atBegin: true
}
......@@ -83,7 +102,7 @@ module.exports = function (grunt) {
files: {
'po/template.pot': ['app/**/*.html']
}
},
}
},
nggettext_compile: {
all: {
......@@ -96,16 +115,68 @@ module.exports = function (grunt) {
'app/shared/translations.js': ['po/*.po']
}
}
},
env: {
options: {
/* Shared Options Hash */
//globalOption : 'foo'
},
dev: {
NODE_ENV: 'DEVELOPMENT'
},
prod: {
NODE_ENV: 'PRODUCTION'
}
},
connect: {
server: {
options: {
port: 8080,
base: 'app'
}
}
},
preprocess : {
dev: {
src: 'index.html',
dest: 'app/index.html'
},
prod: {
src: 'index.html',
dest: 'dist/index.html',
options: {
context: {
name: '<%= pkg.name %>',
version: '<%= pkg.version %>',
now: '<%= now %>',
ver: '<%= ver %>'
}
}
}
}
});
// Default task(s).
//grunt.registerTask('default', ['uglify']);
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-html2js');
......@@ -113,22 +184,22 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-bower-task');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-angular-gettext');
grunt.loadNpmTasks('grunt-preprocess');
grunt.loadNpmTasks('grunt-env');
// todo: reorganize dev and other tasks
grunt.registerTask('dev', ['bower', 'connect:server', 'watch:dev']);
grunt.registerTask('test', ['bower', 'jshint', 'karma:continuous']);
grunt.registerTask('minified', ['bower', 'connect:server', 'watch:min']);
grunt.registerTask('extract_i18n', ['nggettext_extract']);
grunt.registerTask('compile_i18n', ['nggettext_compile']);
grunt.registerTask('dev', ['bower', 'env:dev', 'preprocess:dev', 'connect:server', 'watch:dev']);
grunt.registerTask('test', ['bower', 'karma:continuous']);
grunt.registerTask('i18n', ['nggettext_extract', 'nggettext_compile']);
grunt.registerTask('default', [
'bower',
'html2js:dist',
'concat:dist',
'concat:components',
'uglify:dist',
'nggettext_extract',
'nggettext_compile'
'nggettext_compile',
'concat:js',
'concat:css',
'concat:components',
'env:prod',
'preprocess:prod',
'html2js:prod',
'uglify:dist'
]);
};
\ No newline at end of file
......@@ -8,30 +8,20 @@
'use strict';
var app = angular.module(
'zaerp', [
'ulakbus', [
'ngRoute',
'ngSanitize',
'ngCookies',
'general',
'formService',
'zaerp.dashboard',
'zaerp.auth',
'zaerp.staff',
'zaerp.student',
'ulakbus.dashboard',
'ulakbus.auth',
'ulakbus.staff',
'ulakbus.student',
'schemaForm',
'gettext'
'gettext',
'templates-prod'
]).
/**
* lazyload modules with oclazyload
* the lines below are config of oclazyload
* turn debug false when production
*/
//config(['$ocLazyLoadProvider', function ($ocLazyLoadProvider) {
// $ocLazyLoadProvider.config({
// // todo: turn debug false on prod
// debug: false
// });
//}]).
/**
* RESTURL is the url of rest api to talk
* Based on the environment it changes from dev to prod
......@@ -103,6 +93,6 @@ var app = angular.module(
});
// test the code with strict di mode to see if it works when minified
//angular.bootstrap(document, ['zaerp'], {
//angular.bootstrap(document, ['ulakbus'], {
// strictDi: true
//});
......@@ -7,7 +7,7 @@
'use strict';
var auth = angular.module('zaerp.auth', ['ngRoute', 'schemaForm', 'ngCookies', 'general']);
var auth = angular.module('ulakbus.auth', ['ngRoute', 'schemaForm', 'ngCookies', 'general']);
auth.controller('LoginCtrl', function ($scope, $q, $timeout, $routeParams, Generator, LoginService) {
$scope.url = 'simple_login';
var form_params = {};
......
......@@ -9,16 +9,16 @@
// TODO: fill up the test cases correctly
describe('zaerp.auth module', function () {
describe('ulakbus.auth module', function () {
// load dependencies of modules e.g REST_URL
beforeEach(module('zaerp'));
beforeEach(module('zaerp.auth'));
beforeEach(module('ulakbus'));
beforeEach(module('ulakbus.auth'));
describe('login controller and service', function () {
it('should have a login controller', inject(function () {
expect('zaerp.auth.LoginCtrl').toBeDefined();
expect('ulakbus.auth.LoginCtrl').toBeDefined();
}));
it('should validate email', inject(['LoginService',
......
<div ng-app="zaerp.auth">
<div ng-app="ulakbus.auth">
<div class="col-md-6">
<h1>Ulakbüs Login Form</h1>
<span class="label label-warning">{{message}}</span>
......
......@@ -2,7 +2,7 @@
* Created by Evren Kutar on 18/05/15.
*/
angular.module('zaerp.login.directives', [])
angular.module('ulakbus.login.directives', [])
/**
* Simple directive to check password equality
*
......
<div ng-app="zaerp.dashboard">
<div ng-app="ulakbus.dashboard">
<div class="starter-template">
<h1>Main Dashboard</h1>
{{ testData }}
......
......@@ -9,7 +9,7 @@
// TODO: clean console log items
angular.module('zaerp.dashboard', ['ngRoute'])
angular.module('ulakbus.dashboard', ['ngRoute'])
.controller('DashCtrl', function ($scope) {
$scope.testData = "<h1>This is main Dashboard</h1>";
......
......@@ -8,7 +8,7 @@
'use strict';
var staff = angular.module('zaerp.staff', ['ngRoute', 'schemaForm', 'formService']);
var staff = angular.module('ulakbus.staff', ['ngRoute', 'schemaForm', 'formService', 'ui.bootstrap']);
/**
......
......@@ -9,8 +9,8 @@
describe('staff controller module', function () {
beforeEach(module('zaerp'));
beforeEach(module('zaerp.staff'));
beforeEach(module('ulakbus'));
beforeEach(module('ulakbus.staff'));
var $controller;
......
<div ng-app="zaerp.staff">
<div class="col-md-6">
<h1>{{ schema.title }}</h1>
<form name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
</div>
<div ng-app="ulakbus.staff">
<ng-include src="'shared/templates/add.html'"></ng-include>
</div>
\ No newline at end of file
<div ng-app="zaerp.staff">
<div ng-app="ulakbus.staff">
<div class="col-md-6">
<h1>{{ schema.title }}</h1>
<form name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
......
<div ng-app="zaerp.student">
<div ng-app="ulakbus.student">
<div class="col-md-6">
<h1>{{ schema.title }}</h1>
<form name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
......
......@@ -11,7 +11,7 @@
* student module is base module object for student operations
*/
var student = angular.module('zaerp.student', ['ngRoute', 'schemaForm', 'formService', 'general']);
var student = angular.module('ulakbus.student', ['ngRoute', 'schemaForm', 'formService', 'general']);
/**
* StudentAddEditCtrl
......
......@@ -8,7 +8,7 @@
'use strict';
var staff = angular.module('zaerp.types',['ngRoute','schemaForm', 'formService']);
var staff = angular.module('ulakbus.types',['ngRoute','schemaForm', 'formService']);
staff.controller('TypeCtrl', function($scope, $http, $log, Generator, $routeParams){
Generator.get_form('input_types', $routeParams).then(function(d){
......
<div ng-app="zaerp.types">
<div ng-app="ulakbus.types">
<div class="col-md-6">
<h1>{{ schema.title }}</h1>
<form name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
......
'use strict';
angular.module('zaerp.version.interpolate-filter', [])
angular.module('ulakbus.version.interpolate-filter', [])
.filter('interpolate', ['version', function(version) {
return function(text) {
......
'use strict';
describe('zaerp.version module', function() {
beforeEach(module('zaerp.version'));
describe('ulakbus.version module', function() {
beforeEach(module('ulakbus.version'));
describe('interpolate filter', function() {
beforeEach(module(function($provide) {
......
'use strict';
angular.module('zaerp.version.version-directive', [])
angular.module('ulakbus.version.version-directive', [])
.directive('appVersion', ['version', function(version) {
return function(scope, elm, attrs) {
......
'use strict';
describe('zaerp.version module', function() {
beforeEach(module('zaerp.version'));
describe('ulakbus.version module', function() {
beforeEach(module('ulakbus.version'));
describe('app-version directive', function() {
it('should print current version', function() {
......
'use strict';
angular.module('zaerp.version', [
'zaerp.version.interpolate-filter',
'zaerp.version.version-directive'
angular.module('ulakbus.version', [
'ulakbus.version.interpolate-filter',
'ulakbus.version.version-directive'
])
.value('version', '0.1');
'use strict';
describe('zaerp.version module', function() {
beforeEach(module('zaerp.version'));
describe('ulakbus.version module', function() {
beforeEach(module('ulakbus.version'));
describe('version service', function() {
it('should return current version', inject(function(version) {
......
<!DOCTYPE html>
<!--[if lt IE 7]>
<html lang="en" ng-app="zaerp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<html lang="en" ng-app="ulakbus" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>
<html lang="en" ng-app="zaerp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<html lang="en" ng-app="ulakbus" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>
<html lang="en" ng-app="zaerp" class="no-js lt-ie9"> <![endif]-->
<html lang="en" ng-app="ulakbus" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html lang="en" ng-app="zaerp" class="no-js"> <!--<![endif]-->
<html lang="en" ng-app="ulakbus" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ULAKBUS</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="bower_components/angular-bootstrap/ui-bootstrap-csp.css">
<link rel="stylesheet"
href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="app.css">
<!--<link rel="stylesheet" href="bower_components/quantumui/dist/css/addon/effect-light.min.css">-->
<!--<link rel="stylesheet" href="bower_components/quantumui/dist/css/quantumui.min.css">-->
<link rel="stylesheet" href="app.css">
<!--<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>-->
</head>
<body>
......@@ -71,7 +71,7 @@
<hr>
<div>ZaerpUI app: v<span app-version></span></div>
<div>UlakbusUI app: v<span app-version></span></div>
</div>
</div>
......@@ -79,7 +79,7 @@
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/oclazyload/dist/ocLazyLoad.js"></script>
<!--<script src="bower_components/oclazyload/dist/ocLazyLoad.js"></script>-->
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
......@@ -117,5 +117,6 @@
<script src="components/student/student_controller.js"></script>
<script src="components/dashboard/dashboard.js"></script>
<!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>-->
</body>
</html>
......@@ -32,5 +32,5 @@ $script([
"components/dashboard/dashboard.js"
], function() {
// when all is done, execute bootstrap angular application
angular.bootstrap(document, ['zaerp']);
angular.bootstrap(document, ['ulakbus']);
});
\ No newline at end of file
......@@ -9,7 +9,7 @@
describe('form service module', function () {
beforeEach(module('zaerp'));
beforeEach(module('ulakbus'));
beforeEach(module('formService'));
describe('form service', function () {
......
......@@ -20,7 +20,7 @@ describe('my app', function () {
it('should redirect to login page if not logged in', function () {
expect(element.all(by.css('[ng-view] h1')).first().getText()).
toMatch(/Zaerp Login Form/);
toMatch(/Ulakbus Login Form/);
});
});
......@@ -35,7 +35,7 @@ describe('my app', function () {
it('should render view2 when user navigates to /view2', function () {
expect(element.all(by.css('[ng-view] h1')).first().getText()).
toMatch(/Zaerp Login Form/);
toMatch(/Ulakbus Login Form/);
});
});
......
<!DOCTYPE html>
<!--[if lt IE 7]>
<html lang="en" ng-app="ulakbus" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>
<html lang="en" ng-app="ulakbus" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>
<html lang="en" ng-app="ulakbus" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html lang="en" ng-app="ulakbus" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ULAKBUS</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- @if NODE_ENV == 'DEVELOPMENT' -->
<link rel="stylesheet"
href="bower_components/angular-bootstrap/ui-bootstrap-csp.css">
<link rel="stylesheet"
href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="app.css">
<!--<link rel="stylesheet" href="bower_components/quantumui/dist/css/addon/effect-light.min.css">-->
<!--<link rel="stylesheet" href="bower_components/quantumui/dist/css/quantumui.min.css">-->
<!-- @endif -->
<!-- @if NODE_ENV == 'PRODUCTION' -->
<link rel="stylesheet" href="app.css">
<!-- @endif -->
<!--<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>-->
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed"
data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">ULAKBUS</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#/dashboard" translate>Dashboard</a></li>
<li><a href="#/login"translate>Login</a></li>
<li><a href="javascript:void(0);" logout translate>Logout</a></li>
</ul>
<form class="navbar-form navbar-right">
<input type="text" class="form-control" placeholder="Search...">
</form>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<!--<li active-link="active"><a href="#/students">Students</a></li>-->
<!--<li active-link="active"><a href="#/student/add">New Student</a></li>-->
<li active-link="active"><a href="#/staffs" translate>Staffs
</a></li>
<li active-link="active"><a href="#/staff/add" translate>New Staff</a>
</li>
<!--<li active-link="active"><a href="#/input_types">Types</a></li>-->
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"
ng-view>
</div>
<hr>
<div>UlakbusUI app: v<span app-version></span></div>
</div>
</div>
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<!-- @if NODE_ENV == 'DEVELOPMENT' -->
<script src="bower_components/angular/angular.js"></script>
<!--<script src="bower_components/oclazyload/dist/ocLazyLoad.js"></script>-->
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/tv4/tv4.js"></script>
<script src="bower_components/objectpath/lib/ObjectPath.js"></script>
<script src="bower_components/angular-schema-form/dist/schema-form.js"></script>
<script src="bower_components/angular-schema-form/dist/bootstrap-decorator.js"></script>
<!--<script type="text/javascript"-->
<!--src="bower_components/angular-schema-form-datepicker/"></script>-->
<script src="bower_components/angular-schema-form-datepicker/bootstrap-datepicker.js"></script>
<script src="bower_components/angular-gettext/dist/angular-gettext.min.js"></script>
<script src="shared/translations.js"></script>
<script src="app.js"></script>
<script src="app_routes.js"></script>
<script src="zetalib/interceptors.js"></script>
<script src="zetalib/general.js"></script>
<script src="zetalib/forms/form_service.js"></script>
<!-- components -->
<script src="components/auth/auth_controller.js"></script>
<script src="components/auth/auth_service.js"></script>
<script src="components/dashboard/dashboard_controller.js"></script>
<script src="components/staff/staff_controller.js"></script>
<script src="components/student/student_controller.js"></script>
<script src="components/dashboard/dashboard.js"></script>
<!--<script src="bower_components/quantumui/dist/js/quantumui-nojq.js"></script>-->
<!-- @endif -->
<!-- @if NODE_ENV == 'PRODUCTION' -->
<script src="bower_components/components.js"></script>
<script src="shared/translations.js"></script>
<script src="templates.js"></script>
<script src="app.js"></script>
<!-- @endif -->
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment