From 68d2c3cb79be183c36893fc527233c676a54b794 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 8 May 2014 10:01:46 -0400 Subject: [PATCH] use bower for deps install; TODO: update docs Signed-off-by: Bill Erickson --- .gitignore | 1 + Open-ILS/web/js/ui/default/staff/Gruntfile.js | 89 +++++++++++++++++----- Open-ILS/web/js/ui/default/staff/README.install | 1 + Open-ILS/web/js/ui/default/staff/bower.json | 30 ++++++++ Open-ILS/web/js/ui/default/staff/package.json | 14 +--- .../web/js/ui/default/staff/test/karma.conf.js | 10 +-- 6 files changed, 112 insertions(+), 33 deletions(-) create mode 100644 Open-ILS/web/js/ui/default/staff/bower.json diff --git a/.gitignore b/.gitignore index 94d7ff2ecb..b42b3d4eff 100644 --- a/.gitignore +++ b/.gitignore @@ -354,3 +354,4 @@ Open-ILS/xul/staff_client/xulrunner-stub.exe /JavaScript* Open-ILS/web/js/ui/default/staff/build/ Open-ILS/web/js/ui/default/staff/node_modules/ +Open-ILS/web/js/ui/default/staff/bower_components/ diff --git a/Open-ILS/web/js/ui/default/staff/Gruntfile.js b/Open-ILS/web/js/ui/default/staff/Gruntfile.js index 2065d95c51..52cf0bec85 100644 --- a/Open-ILS/web/js/ui/default/staff/Gruntfile.js +++ b/Open-ILS/web/js/ui/default/staff/Gruntfile.js @@ -4,26 +4,68 @@ module.exports = function(grunt) { var config = { pkg: grunt.file.readJSON('package.json'), - // copy the JS files we care about from node-fetched dependencies + // copy the files we care about from bower-fetched dependencies // into our build directory copy: { - main: { + + js : { files: [{ - dest: 'build/', + dest: 'build/js/', flatten: true, filter: 'isFile', expand : true, src: [ - 'node_modules/angular/lib/angular.min.js', - 'node_modules/angular-route/angular-route.min.js', - 'node_modules/angular-bootstrap/ui-bootstrap.js', - 'node_modules/angular-hotkeys/build/hotkeys.min.js' + 'bower_components/angular/angular.min.js', + 'bower_components/angular-route/angular-route.min.js', + 'bower_components/angular-bootstrap/ui-bootstrap.min.js', + 'bower_components/angular-hotkeys/build/hotkeys.min.js', + ] + }] + }, + + css : { + files : [{ + dest : 'build/css/', + flatten : true, + filter : 'isFile', + expand : true, + src : [ + 'bower_components/angular-hotkeys/build/hotkeys.min.css', + 'bower_components/bootstrap/dist/css/bootstrap.min.css' + ] + }] + }, + + fonts : { + files : [{ + dest : 'build/fonts/', + flatten : true, + filter : 'isFile', + expand : true, + src : [ + 'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot', + 'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg', + 'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf', + 'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff' ] }] } }, - // confiure minification + // combine our CSS deps + // note: minification also supported, but not required (yet). + cssmin: { + combine: { + files: { + 'build/css/evergreen-staff-client-deps.<%= pkg.version %>.css' : [ + 'build/css/hotkeys.min.css', + 'build/css/bootstrap.min.css' + ] + } + } + }, + + // concatenation + minification uglify: { options: { banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' @@ -32,10 +74,10 @@ module.exports = function(grunt) { src: [ // These are concatenated in order in the final build file. // The order is important. - 'build/angular.min.js', - 'build/angular-route.min.js', - 'build/ui-bootstrap.js', - 'build/hotkeys.min.js', + 'build/js/angular.min.js', + 'build/js/angular-route.min.js', + 'build/js/ui-bootstrap.min.js', + 'build/js/hotkeys.min.js', // NOTE: OpenSRF must be installed '/openils/lib/javascript/JSON_v1.js', '/openils/lib/javascript/opensrf.js', @@ -52,22 +94,30 @@ module.exports = function(grunt) { 'services/startup.js', 'services/hatch.js', 'services/coresvc.js', + 'services/navbar.js', 'services/statusbar.js', 'services/ui.js', - 'navbar.js' ], - dest: 'build/<%= pkg.name %>.<%= pkg.version %>.min.js' + dest: 'build/js/<%= pkg.name %>.<%= pkg.version %>.min.js' } }, // bare concat operation; useful for testing concat w/o minification - // to more easily detect when concat order is incorrect + // to more easily detect if concat order is incorrect concat: { options: { separator: ';', } }, + // generate test/data/IDL2js.js + exec : { + idl2js : { + command : 'cd test/data && perl idl2js.pl', + stdout : true + } + }, + // unit tests configuration karma : { unit: { @@ -87,12 +137,15 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-karma'); + grunt.loadNpmTasks('grunt-exec'); // note: "grunt concat" is not requried - grunt.registerTask('all', ['copy', 'karma:unit', 'uglify']); + grunt.registerTask('all', ['copy', 'exec', 'karma:unit', 'cssmin', 'uglify']); // test only, no minification - grunt.registerTask('test', ['copy', 'karma:unit']); - + grunt.registerTask('test', ['copy', 'exec', 'karma:unit']); }; + +// vim: ts=2:sw=2:softtabstop=2 diff --git a/Open-ILS/web/js/ui/default/staff/README.install b/Open-ILS/web/js/ui/default/staff/README.install index bc299d8224..92a1076454 100644 --- a/Open-ILS/web/js/ui/default/staff/README.install +++ b/Open-ILS/web/js/ui/default/staff/README.install @@ -97,4 +97,5 @@ but the IDL JS is generated from the in-repo fm_IDL.xml file via a script: ** Avoid installing test, node_modules, etc. into the web dir. * Support fetching JS deps (angularjs, etc.) via direct retrieval for installation without test + concat + minify (i.e. w/o requiring Node.js)? + * CSS minification diff --git a/Open-ILS/web/js/ui/default/staff/bower.json b/Open-ILS/web/js/ui/default/staff/bower.json new file mode 100644 index 0000000000..8c2ed1f4e6 --- /dev/null +++ b/Open-ILS/web/js/ui/default/staff/bower.json @@ -0,0 +1,30 @@ +{ + "name": "evergreen-staff-client", + "version": "0.0.1", + "authors": [ + "Bill Erickson " + ], + "description": "Evergreen HTML Staff Client", + "keywords": [ + "evergreen" + ], + "license": "GPL", + "homepage": "http://evergreen-ils.org", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "devDependencies": { + "bootstrap": "~3.1.1", + "angular": "~1.2.16", + "angular-route": "~1.2.16", + "angular-mocks": "~1.2.16", + "angular-bootstrap": "~0.11.0" + }, + "dependencies": { + "angular-hotkeys": "chieffancypants/angular-hotkeys#~1.2.0" + } +} diff --git a/Open-ILS/web/js/ui/default/staff/package.json b/Open-ILS/web/js/ui/default/staff/package.json index 0350437ba4..d423fd401c 100644 --- a/Open-ILS/web/js/ui/default/staff/package.json +++ b/Open-ILS/web/js/ui/default/staff/package.json @@ -5,29 +5,23 @@ "license": "GPL", "homepage": "http://evergreen-ils.org/", "devDependencies": { - "angular": "^1.2.16", - "angular-bootstrap": "0.0.4", - "angular-hotkeys": "^1.2.0", + "bower": "^1.3.3", "grunt": "~0.4.4", "grunt-cli": "^0.1.13", "grunt-contrib-concat": "^0.4.0", "grunt-contrib-copy": "^0.5.0", + "grunt-contrib-cssmin": "^0.9.0", "grunt-contrib-jasmine": "^0.6.4", "grunt-contrib-uglify": "^0.4.0", + "grunt-exec": "^0.4.5", "grunt-karma": "^0.8.3", "karma": "^0.12.14", "karma-jasmine": "^0.1.5", "karma-phantomjs-launcher": "^0.1.4", "karma-script-launcher": "~0.1.0", - "karma-story-reporter": "^0.2.2", - "napa": "^0.4.1" - }, - "napa": { - "angular-route": "angular/bower-angular-route", - "angular-mocks": "angular/bower-angular-mocks" + "karma-story-reporter": "^0.2.2" }, "scripts": { - "install": "napa", "test": "grunt test" } } diff --git a/Open-ILS/web/js/ui/default/staff/test/karma.conf.js b/Open-ILS/web/js/ui/default/staff/test/karma.conf.js index 235c7b4861..88a60ef2b7 100644 --- a/Open-ILS/web/js/ui/default/staff/test/karma.conf.js +++ b/Open-ILS/web/js/ui/default/staff/test/karma.conf.js @@ -6,11 +6,11 @@ module.exports = function(config){ logLevel: config.LOG_INFO, files : [ - 'build/angular.min.js', - 'build/angular-route.min.js', - 'node_modules/angular-mocks/angular-mocks.js', // testing only - 'build/ui-bootstrap.js', - 'build/hotkeys.min.js', + 'build/js/angular.min.js', + 'build/js/angular-route.min.js', + 'bower_components/angular-mocks/angular-mocks.js', // testing only + 'build/js/ui-bootstrap.min.js', + 'build/js/hotkeys.min.js', /* OpenSRF must be installed first */ '/openils/lib/javascript/md5.js', '/openils/lib/javascript/JSON_v1.js', -- 2.11.0