From d72491110815e508988119c0520703a3459b17d7 Mon Sep 17 00:00:00 2001 From: Helena Eksler Date: Mon, 28 Mar 2016 15:12:39 +0300 Subject: [PATCH 1/3] Add showJsError when developing. Update imagemin version. --- app/templates/client/Gruntfile.js | 7 ++++++- app/templates/client/app/index.html | 14 ++++++++++++-- app/templates/client/bower.json | 3 ++- app/templates/client/package.json | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/templates/client/Gruntfile.js b/app/templates/client/Gruntfile.js index 1774351..896555a 100644 --- a/app/templates/client/Gruntfile.js +++ b/app/templates/client/Gruntfile.js @@ -162,6 +162,11 @@ module.exports = function (grunt) { // Automatically inject Bower components into the app wiredep: { + dev: { + devDependencies: true, + src: ['<%= yeoman.app %>/index.html'], + ignorePath: /\.\.\// + }, app: { src: ['<%= yeoman.app %>/index.html'], ignorePath: /\.\.\// @@ -453,7 +458,7 @@ module.exports = function (grunt) { grunt.task.run([ 'clean:server', 'ngconstant:server', - 'wiredep', + 'wiredep:dev', 'concurrent:server', 'autoprefixer', 'connect:livereload', diff --git a/app/templates/client/app/index.html b/app/templates/client/app/index.html index 0980f12..8714c3b 100644 --- a/app/templates/client/app/index.html +++ b/app/templates/client/app/index.html @@ -37,7 +37,6 @@

Login with demo / 1234

- - @@ -94,5 +92,17 @@

Login with demo / 1234

+ + diff --git a/app/templates/client/bower.json b/app/templates/client/bower.json index 44914b1..7bfb16c 100644 --- a/app/templates/client/bower.json +++ b/app/templates/client/bower.json @@ -19,7 +19,8 @@ "angular-scenario": "~1.3.0", "angular": "~1.4.0", "json3": "~3.3.2", - "es5-shim": "~4.1.6" + "es5-shim": "~4.1.6", + "show-js-error" : "1.2.0" }, "appPath": "app", "resolutions": { diff --git a/app/templates/client/package.json b/app/templates/client/package.json index a0e7508..9cdfa7c 100644 --- a/app/templates/client/package.json +++ b/app/templates/client/package.json @@ -14,7 +14,7 @@ "grunt-contrib-copy": "^0.8.0", "grunt-contrib-cssmin": "^0.12.3", "grunt-contrib-htmlmin": "^0.4.0", - "grunt-contrib-imagemin": "^0.9.4", + "grunt-contrib-imagemin": "^1.0.0", "grunt-contrib-jshint": "^0.11.2", "grunt-contrib-uglify": "^0.9.1", "grunt-contrib-watch": "^0.6.1", From 93fdff089d55844def1f6f2ecc2a143485bc656b Mon Sep 17 00:00:00 2001 From: Helena Eksler Date: Thu, 31 Mar 2016 08:08:30 +0300 Subject: [PATCH 2/3] Show Javascript and Angular errors in popup on development. --- app/templates/client/Gruntfile.js | 18 +++++++++++++-- .../app/dev-scripts/show-js-error-init.js | 9 ++++++++ app/templates/client/app/index.html | 22 +++++++++---------- app/templates/client/app/scripts/app.js | 11 +++++++++- app/templates/client/package.json | 1 + 5 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 app/templates/client/app/dev-scripts/show-js-error-init.js diff --git a/app/templates/client/Gruntfile.js b/app/templates/client/Gruntfile.js index 896555a..eb3cf4a 100644 --- a/app/templates/client/Gruntfile.js +++ b/app/templates/client/Gruntfile.js @@ -34,7 +34,7 @@ module.exports = function (grunt) { tasks: ['wiredep'] }, js: { - files: ['<%= yeoman.app %>/scripts/{,*/}*.js'], + files: ['<%= yeoman.app %>/scripts/{,*/}*.js', '<%= yeoman.app %>/dev-scripts/{,*/}*.js'], tasks: ['newer:jshint:all'], options: { livereload: '<%= connect.options.livereload %>' @@ -165,7 +165,8 @@ module.exports = function (grunt) { dev: { devDependencies: true, src: ['<%= yeoman.app %>/index.html'], - ignorePath: /\.\.\// + ignorePath: /\.\.\//, + exclude: ['bower_components/show-js-error/dist/show-js-error.js'] }, app: { src: ['<%= yeoman.app %>/index.html'], @@ -446,6 +447,18 @@ module.exports = function (grunt) { push: true } } + }, + + includeSource: { + options: { + basePath: 'app', + baseUrl: '/' + }, + server: { + files: { + '<%= yeoman.app %>/index.html': '<%= yeoman.app %>/index.html' + } + } } }); @@ -459,6 +472,7 @@ module.exports = function (grunt) { 'clean:server', 'ngconstant:server', 'wiredep:dev', + 'includeSource:server', 'concurrent:server', 'autoprefixer', 'connect:livereload', diff --git a/app/templates/client/app/dev-scripts/show-js-error-init.js b/app/templates/client/app/dev-scripts/show-js-error-init.js new file mode 100644 index 0000000..11ad89d --- /dev/null +++ b/app/templates/client/app/dev-scripts/show-js-error-init.js @@ -0,0 +1,9 @@ +// Use showJsError bower component if exists. +if (typeof showJSError !== 'undefined') { + showJSError.init({ + title: 'JavaScript error', + userAgent: navigator.userAgent, + sendText: 'Send', + sendUrl: 'https://github.com/repoName/issues/new?title={title}&body={body}' + }); +} diff --git a/app/templates/client/app/index.html b/app/templates/client/app/index.html index 8714c3b..d13c857 100644 --- a/app/templates/client/app/index.html +++ b/app/templates/client/app/index.html @@ -11,6 +11,7 @@ + @@ -68,10 +69,19 @@

Login with demo / 1234

+ + + + + + + + + @@ -91,18 +101,8 @@

Login with demo / 1234

+ - diff --git a/app/templates/client/app/scripts/app.js b/app/templates/client/app/scripts/app.js index 4ff7176..3eb6522 100644 --- a/app/templates/client/app/scripts/app.js +++ b/app/templates/client/app/scripts/app.js @@ -19,7 +19,7 @@ angular 'ui.router', 'angular-loading-bar' ]) - .config(function($stateProvider, $urlRouterProvider, $httpProvider, cfpLoadingBarProvider) { + .config(function($stateProvider, $urlRouterProvider, $httpProvider, cfpLoadingBarProvider, $provide) { /** * Redirect a user to a 403 error page. @@ -190,6 +190,15 @@ angular // Configuration of the loading bar. cfpLoadingBarProvider.includeSpinner = false; cfpLoadingBarProvider.latencyThreshold = 1000; + + // Catch angular errors and show them in popup. + $provide.decorator("$exceptionHandler", function($delegate, $injector){ + if (typeof showJSError !== 'undefined') { + return function(exception, cause){ + showJSError.show(exception); + }; + } + }); }) .run(function ($rootScope, $state, $stateParams, $log, Config) { // It's very handy to add references to $state and $stateParams to the diff --git a/app/templates/client/package.json b/app/templates/client/package.json index 9cdfa7c..32dfdeb 100644 --- a/app/templates/client/package.json +++ b/app/templates/client/package.json @@ -20,6 +20,7 @@ "grunt-contrib-watch": "^0.6.1", "grunt-filerev": "^2.3.1", "grunt-google-cdn": "^0.4.3", + "grunt-include-source": "^0.7.1", "grunt-newer": "^1.1.1", "grunt-ng-annotate": "^1.0.1", "grunt-ng-constant": "^1.1.0", From 14c98437fcf66e51788f1a830605c8d96edf4d17 Mon Sep 17 00:00:00 2001 From: Helena Eksler Date: Thu, 31 Mar 2016 09:33:28 +0300 Subject: [PATCH 3/3] Include custom script only on dev. --- app/templates/client/app/index.html | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/templates/client/app/index.html b/app/templates/client/app/index.html index d13c857..5227ecc 100644 --- a/app/templates/client/app/index.html +++ b/app/templates/client/app/index.html @@ -77,13 +77,16 @@

Login with demo / 1234

- - - - - + + + + + + + +