summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-12-09 12:31:09 -0200
committerDuda Dornelles <ddornell@thoughtworks.com>2014-12-09 18:20:48 -0200
commit788fd1f471473f4cdfd58f8dc51f8c59cf236e67 (patch)
tree879b0d1e47b1f21b57152dde71200f730b211d90
parent0b8600a47d2f9ae6d10bfeb059f032c65bbc3ccb (diff)
Getting rid of grunt; using npm scripts instead
-rw-r--r--web-ui/Gruntfile.js476
-rw-r--r--web-ui/app/index.html6
-rw-r--r--web-ui/app/js/views/templates.js2
-rw-r--r--web-ui/app/scss/main.scss8
-rw-r--r--web-ui/app/scss/styles.scss14
-rw-r--r--web-ui/app/templates/compose/no_message_selected.hbs (renamed from web-ui/app/templates/no_message_selected.hbs)0
-rw-r--r--web-ui/bower.json2
-rw-r--r--web-ui/config/buildoptions.js11
-rw-r--r--web-ui/config/compass.rb29
-rw-r--r--web-ui/config/imagemin.js14
-rw-r--r--web-ui/config/package.sh36
-rwxr-xr-xweb-ui/go2
-rw-r--r--web-ui/package.json56
13 files changed, 123 insertions, 533 deletions
diff --git a/web-ui/Gruntfile.js b/web-ui/Gruntfile.js
deleted file mode 100644
index 8a04a9fd..00000000
--- a/web-ui/Gruntfile.js
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * Copyright (c) 2014 ThoughtWorks, Inc.
- *
- * Pixelated is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Pixelated is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
- */
-'use strict';
-
-// # Globbing
-// for performance reasons we're only matching one level down:
-// 'test/spec/{,*/}*.js'
-// use this if you want to recursively match all subfolders:
-// 'test/spec/**/*.js'
-
-module.exports = function (grunt) {
- var exec = require('child_process').exec;
-
- // Load grunt tasks automatically
- require('load-grunt-tasks')(grunt);
-
- // Time how long tasks take. Can help when optimizing build times
- require('time-grunt')(grunt);
-
- // Define the configuration for all the tasks
- grunt.initConfig({
- compress: {
- main: {
- options: {
- archive: 'archive.zip'
- },
- files: [
- {src: ['dist/**/*']} // includes files in path
- ]
- }
- },
-
- // Project settings
- yeoman: {
- // configurable paths
- app: require('./bower.json').appPath || 'app',
- dist: 'dist'
- },
-
- // Watches files for changes and runs tasks based on the changed files
- watch: {
- js: {
- files: ['{.tmp,<%= yeoman.app %>}/js/{,*/}*.js'],
- tasks: ['newer:jshint:all', 'update-control-tower']
- },
- jsTest: {
- files: ['test/spec/{,*/}*.js'],
- tasks: ['newer:jshint:test', 'karma']
- },
- sass: {
- files: ['<%= yeoman.app %>/scss/{,*/}*.scss'],
- tasks: ['compass:dev']
- },
- html: {
- files: ['<%= yeoman.app %>/index.html'],
- livereload: true
- },
- templates: {
- files: ['<%= yeoman.app %>/templates/**/*.hbs'],
- tasks: ['handlebars:dev']
- },
- gruntfile: {
- files: ['Gruntfile.js']
- }
- },
-
- compass: {
- dist: {
- options: {
- sassDir: '<%= yeoman.app %>/scss',
- cssDir: '<%= yeoman.dist %>/css',
- environment: 'production'
- }
- },
- dev: {
- options: {
- sassDir: '<%= yeoman.app %>/scss',
- cssDir: 'app/css'
- }
- }
- },
-
- // The actual grunt server settings
- connect: {
- options: {
- port: 9000,
- // Change this from '0.0.0.0' to 'localhost' to limit access from outside.
- hostname: '0.0.0.0',
- livereload: true
- },
- test: {
- options: {
- port: 9001,
- base: [
- '.tmp',
- 'test',
- '<%= yeoman.app %>'
- ]
- }
- },
- dist: {
- options: {
- base: '<%= yeoman.dist %>'
- }
- }
- },
-
- // Make sure code styles are up to par and there are no obvious mistakes
- jshint: {
- options: {
- jshintrc: '.jshintrc',
- reporter: require('jshint-stylish')
- },
- all: [
- 'Gruntfile.js',
- '<%= yeoman.app %>/scripts/{,*/}*.js'
- ],
- test: {
- options: {
- jshintrc: '.jshintrc'
- },
- src: ['test/spec/{,*/}*.js']
- }
- },
-
- // Empties folders to start fresh
- clean: {
- dist: {
- files: [{
- dot: true,
- src: [
- '.tmp',
- '<%= yeoman.dist %>/*',
- ]
- }]
- },
- server: ['.tmp', '<%= yeoman.app %>/js/generated']
- },
-
- uglify: {
- dist: {
- files: [{
- expand: true,
- cwd: '.tmp',
- src: 'app.min.js',
- dest: 'dist'
- }]
- }
- },
-
- cssmin: {
- minify: {
- expand: true,
- cwd: '<%= yeoman.app %>/css/',
- src: ['*.css', '!*.min.css'],
- dest: '<%= yeoman.dist %>/css/'
- }
- },
-
- // The following *-min tasks produce minified files in the dist folder
- imagemin: {
- dist: {
- files: [{
- expand: true,
- cwd: '<%= yeoman.app %>/images',
- src: '{,*/}*.{png,jpg,jpeg,gif}',
- dest: '<%= yeoman.dist %>/images'
- }]
- }
- },
-
- svgmin: {
- dist: {
- files: [{
- expand: true,
- cwd: '<%= yeoman.app %>/images',
- src: '{,*/}*.svg',
- dest: '<%= yeoman.dist %>/images'
- }]
- }
- },
-
- htmlmin: {
- dist: {
- options: {
- // Optional configurations that you can uncomment to use
- // removeCommentsFromCDATA: true,
- // collapseBooleanAttributes: true,
- // removeAttributeQuotes: true,
- // removeRedundantAttributes: true,
- // useShortDoctype: true,
- // removeEmptyAttributes: true,
- // removeOptionalTags: true*/
- },
- files: [{
- expand: true,
- cwd: '<%= yeoman.app %>',
- src: ['*.html', 'templates/*.html'],
- dest: '<%= yeoman.dist %>'
- }]
- }
- },
-
- // Allow the use of non-minsafe AngularJS files. Automatically makes it
- // minsafe compatible so Uglify does not destroy the ng references
- // Replace Google CDN references
- cdnify: {
- dist: {
- html: ['<%= yeoman.dist %>/*.html']
- }
- },
-
- // Copies remaining files to places other tasks can use
- copy: {
- dist: {
- files: [{
- expand: true,
- dot: true,
- cwd: '<%= yeoman.app %>',
- dest: '<%= yeoman.dist %>',
- src: [
- '*.{ico,png,txt}',
- '.htaccess',
- 'images/{,*/}*.{webp}',
- 'fonts/*',
- 'templates/*',
- 'locales/**/*',
- 'bower_components/font-awesome/css/font-awesome.min.css',
- 'bower_components/font-awesome/fonts/*'
- ]
- }, {
- expand: true,
- cwd: '.tmp/images',
- dest: '<%= yeoman.dist %>/images',
- src: [
- 'generated/*'
- ]
- }]
- },
- styles: {
- expand: true,
- cwd: '<%= yeoman.app %>/styles',
- dest: '.tmp/css/',
- src: '{,*/}*.css'
- }
- },
-
- // Run some tasks in parallel to speed up the build process
- concurrent: {
- server: [
- 'copy:styles'
- ],
- test: [
- 'copy:styles'
- ],
- dist: [
- 'copy:styles',
- 'imagemin',
- 'svgmin',
- 'htmlmin'
- ]
- },
- requirejs: {
- compile: {
- options: {
- baseUrl: 'app',
- wrap: true,
- almond: true,
- optimize: 'none',
- mainConfigFile: 'app/js/main.js',
- out: '.tmp/app.concatenated.js',
- include: ['js/main'],
- name: 'bower_components/almond/almond'
-
- }
- }
- },
- concat: {
- options: {
- separator: ';',
- },
- dist: {
- src: [
- 'app/bower_components/modernizr/modernizr.js',
- 'app/bower_components/lodash/dist/lodash.js',
- 'app/bower_components/jquery/dist/jquery.js',
- 'app/js/lib/highlightRegex.js',
- 'app/bower_components/handlebars/handlebars.min.js',
- 'app/bower_components/typeahead.js/dist/typeahead.bundle.min.js',
- 'app/bower_components/foundation/js/foundation.js',
- 'app/bower_components/foundation/js/foundation/foundation.reveal.js',
- 'app/bower_components/foundation/js/foundation/foundation.offcanvas.js',
- '.tmp/app.concatenated.js',
- ],
- dest: '.tmp/app.min.js',
- },
- },
- useminPrepare: {
- html: 'dist/index.html',
- options: {
- dest: 'dist'
- }
- },
- usemin: {
- html: 'dist/index.html'
- },
- 'regex-replace': {
- dist: {
- src: ['dist/index.html'],
- actions: [
- {
- name: 'remove-requirejs-from-index',
- search: 'remove-in-build.*end-remove-in-build',
- replace: function(match){
- return '';
- },
- flags: 'g'
- }
- ]
- }
- },
- handlebars: {
- dist: {
- options: {
- namespace: 'Pixelated'
- },
- files: {
- '<%= yeoman.dist %>/js/generated/hbs/templates.js': '<%= yeoman.app %>/templates/**/*.hbs'
- }
- },
- dev: {
- options: {
- namespace: 'Pixelated'
- },
- files: {
- '<%= yeoman.app %>/js/generated/hbs/templates.js': '<%= yeoman.app %>/templates/**/*.hbs'
- }
- }
- },
-
- // Test settings
- karma: {
- options: {
- configFile: 'karma.conf.js'
- },
-
- ci: {
- singleRun: true,
- autoWatch: false,
- colors: false,
- reporters: ['junit']
- },
-
- single: {
- singleRun: true,
- autoWatch: false
- },
-
- dev: {
- singleRun: false,
- browsers: ['PhantomJS']
- },
- debug: {
- singleRun: false,
- browsers: ['Chrome']
- }
-
- }
-
- });
-
- grunt.loadNpmTasks('grunt-contrib-requirejs');
- grunt.loadNpmTasks('grunt-contrib-concat');
-
- grunt.registerTask('build', function (target) {
- if (target === 'dist') {
- return grunt.task.run(['package', 'dist:keepalive']);
- }
-
- grunt.task.run([
- 'clean:server',
- 'compass:dev',
- 'handlebars:dev',
- 'concurrent:server',
- 'update-control-tower'
- ]);
- });
-
- /*
- grunt.registerTask('watch', function (target) {
- grunt.task.run([
- 'build',
- 'watch'
- ]);
- });
- */
-
- grunt.registerTask('test-watch', [
- 'clean:server',
- 'handlebars:dev',
- 'connect:test',
- 'karma:dev'
- ]);
-
- grunt.registerTask('debug', [
- 'clean:server',
- 'handlebars:dev',
- 'connect:test',
- 'karma:debug'
- ]);
-
- grunt.registerTask('test-ci', [
- 'clean:server',
- 'stopbrowsers',
- 'handlebars:dev',
- 'concurrent:test',
- 'connect:test',
- 'karma:ci'
- ]);
-
- grunt.registerTask('test', [
- 'clean:server',
- 'handlebars:dev',
- 'connect:test',
- 'karma:single'
- ]);
-
- grunt.registerTask('package', [
- 'clean:dist',
- 'useminPrepare',
- 'compass:dist',
- 'handlebars:dev',
- 'concurrent:dist',
- 'copy:dist',
- 'cdnify',
- 'cssmin',
- 'requirejs',
- 'concat:dist',
- 'uglify',
- 'usemin',
- 'regex-replace:dist',
- 'compress'
- ]);
-
- grunt.registerTask('default', [
- 'newer:jshint',
- 'test',
- 'package'
- ]);
-
- grunt.registerTask('stopbrowsers', function () {
- ['phantom', 'firefox'].forEach(function (browser) {
- console.log('killing all ' + browser + ' instances');
- exec('pgrep -f "' + browser + '" | xargs kill');
- console.log('... done');
- });
- });
-
- grunt.registerTask('update-control-tower', function () {
- exec('bash -c "flight-control-tower control-tower.yml && mv control_tower.html .tmp/"');
- });
-};
diff --git a/web-ui/app/index.html b/web-ui/app/index.html
index 546a59b6..16521d37 100644
--- a/web-ui/app/index.html
+++ b/web-ui/app/index.html
@@ -61,7 +61,7 @@
</div>
</div>
-<!-- build:js app.min.js -->
+<!--usemin_start-->
<script src="/bower_components/modernizr/modernizr.js"></script>
<script src="/bower_components/lodash/dist/lodash.js"></script>
<script src="/bower_components/jquery/dist/jquery.js"></script>
@@ -71,9 +71,9 @@
<script src="/bower_components/foundation/js/foundation.js" ></script>
<script src="/bower_components/foundation/js/foundation/foundation.reveal.js" ></script>
<script src="/bower_components/foundation/js/foundation/foundation.offcanvas.js"></script>
-<!-- endbuild-->
+<script src="/bower_components/requirejs/require.js" data-main="js/main.js"></script>
+<!--usemin_end-->
-<!-- remove-in-build --><script src="/bower_components/requirejs/require.js" data-main="js/main.js"></script><!-- end-remove-in-build -->
<script>
diff --git a/web-ui/app/js/views/templates.js b/web-ui/app/js/views/templates.js
index 4847eb4d..9d202207 100644
--- a/web-ui/app/js/views/templates.js
+++ b/web-ui/app/js/views/templates.js
@@ -49,7 +49,7 @@ define(['hbs/templates'], function (templates) {
refreshTrigger: window.Pixelated['app/templates/mail_actions/refresh_trigger.hbs'],
paginationTrigger: window.Pixelated['app/templates/mail_actions/pagination_trigger.hbs']
},
- noMessageSelected: window.Pixelated['app/templates/no_message_selected.hbs'],
+ noMessageSelected: window.Pixelated['app/templates/compose/no_message_selected.hbs'],
search: {
trigger: window.Pixelated['app/templates/search/search_trigger.hbs']
},
diff --git a/web-ui/app/scss/main.scss b/web-ui/app/scss/main.scss
index 8489d525..f4ce2c4b 100644
--- a/web-ui/app/scss/main.scss
+++ b/web-ui/app/scss/main.scss
@@ -1,8 +1,8 @@
-@import "reset.scss";
-@import "foundation.scss";
@import "compass/css3";
-@import "colors.scss";
-@import "styles.scss";
+@import "reset";
+@import "foundation";
+@import "colors";
+@import "styles";
html {
diff --git a/web-ui/app/scss/styles.scss b/web-ui/app/scss/styles.scss
index 7fe0ec05..bd7ea2b5 100644
--- a/web-ui/app/scss/styles.scss
+++ b/web-ui/app/scss/styles.scss
@@ -1,11 +1,11 @@
@import "compass/css3";
-@import "colors.scss";
-@import "mixins.scss";
-@import "alerts.scss";
-@import "read.scss";
-@import "reply.scss";
-@import "compose.scss";
-@import "security.scss";
+@import "colors";
+@import "mixins";
+@import "alerts";
+@import "read";
+@import "reply";
+@import "compose";
+@import "security";
#logo {
diff --git a/web-ui/app/templates/no_message_selected.hbs b/web-ui/app/templates/compose/no_message_selected.hbs
index 0442192d..0442192d 100644
--- a/web-ui/app/templates/no_message_selected.hbs
+++ b/web-ui/app/templates/compose/no_message_selected.hbs
diff --git a/web-ui/bower.json b/web-ui/bower.json
index ea8a5f7b..7543a33b 100644
--- a/web-ui/bower.json
+++ b/web-ui/bower.json
@@ -13,7 +13,7 @@
"typeahead.js": "0.10.2"
},
"devDependencies": {
- "handlebars": "~1.3.0",
+ "handlebars": "2.0.0",
"jasmine-flight": "3.0.0",
"jasmine-jquery": "2.0.5",
"almond": "~0.3.0"
diff --git a/web-ui/config/buildoptions.js b/web-ui/config/buildoptions.js
new file mode 100644
index 00000000..639a573e
--- /dev/null
+++ b/web-ui/config/buildoptions.js
@@ -0,0 +1,11 @@
+({
+ baseUrl: '../app',
+ wrap: true,
+ almond: true,
+ optimize: 'none',
+ mainConfigFile: '../app/js/main.js',
+ out: '../.tmp/app.concatenated.js',
+ include: ['js/main'],
+ name: 'bower_components/almond/almond'
+})
+
diff --git a/web-ui/config/compass.rb b/web-ui/config/compass.rb
new file mode 100644
index 00000000..0b9463a7
--- /dev/null
+++ b/web-ui/config/compass.rb
@@ -0,0 +1,29 @@
+# Require any additional compass plugins here.
+
+# Set this to the root of your project when deployed:
+
+target_dir = ENV['PIXELATED_BUILD'] == 'package' ? 'dist' : 'app'
+
+
+http_path = "/"
+css_dir = "#{target_dir}/css"
+sass_dir = "app/scss"
+images_dir = "app/images"
+javascripts_dir = "app/js"
+
+# You can select your preferred output style here (can be overridden via the command line):
+# output_style = :expanded or :nested or :compact or :compressed
+output_style = :compressed
+
+# To enable relative paths to assets via compass helper functions. Uncomment:
+# relative_assets = true
+
+# To disable debugging comments that display the original location of your selectors. Uncomment:
+# line_comments = false
+
+
+# If you prefer the indented syntax, you might want to regenerate this
+# project again passing --syntax sass, or you can uncomment this:
+# preferred_syntax = :sass
+# and then run:
+# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
diff --git a/web-ui/config/imagemin.js b/web-ui/config/imagemin.js
new file mode 100644
index 00000000..d63f7a7c
--- /dev/null
+++ b/web-ui/config/imagemin.js
@@ -0,0 +1,14 @@
+var Imagemin = require('imagemin');
+
+var imagemin = new Imagemin()
+ .src('app/images/*.{gif,jpg,png,svg}')
+ .dest('dist/images')
+ .use(Imagemin.jpegtran({ progressive: true }));
+
+imagemin.run(function (err, files) {
+ if (err) {
+ throw err;
+ }
+
+ console.log(files[0]);
+});
diff --git a/web-ui/config/package.sh b/web-ui/config/package.sh
new file mode 100644
index 00000000..b4e3c17d
--- /dev/null
+++ b/web-ui/config/package.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# prepare files for .deb package
+export PIXELATED_BUILD='package'
+
+mkdir -p dist
+
+# initial npm tasks
+./go clean
+./go compass
+./go handlebars
+./go imagemin
+./go minify_html
+./go buildmain
+
+
+# copy files
+cd app
+cp --parents 404.html fonts/* locales/**/* bower_components/font-awesome/css/font-awesome.min.css bower_components/font-awesome/fonts/* ../dist
+cd -
+
+# concat js files and minify
+cat \
+app/bower_components/modernizr/modernizr.js \
+app/bower_components/lodash/dist/lodash.js \
+app/bower_components/jquery/dist/jquery.js \
+app/js/lib/highlightRegex.js \
+app/bower_components/handlebars/handlebars.min.js \
+app/bower_components/typeahead.js/dist/typeahead.bundle.min.js \
+app/bower_components/foundation/js/foundation.js \
+app/bower_components/foundation/js/foundation/foundation.reveal.js \
+app/bower_components/foundation/js/foundation/foundation.offcanvas.js \
+.tmp/app.concatenated.js > dist/app.js
+node_modules/.bin/minify dist/app.js > dist/app.min.js
+rm dist/app.js
+
diff --git a/web-ui/go b/web-ui/go
index ad575723..8f2f1005 100755
--- a/web-ui/go
+++ b/web-ui/go
@@ -1,3 +1,3 @@
#!/bin/bash
-node_modules/grunt-cli/bin/grunt $GRUNT_OPTS $*
+npm run $*
diff --git a/web-ui/package.json b/web-ui/package.json
index 60736713..d13d42a5 100644
--- a/web-ui/package.json
+++ b/web-ui/package.json
@@ -3,55 +3,31 @@
"version": "0.0.0",
"devDependencies": {
"bower": "1.3.12",
- "connect-livereload": "0.5.2",
- "express": "4.10.4",
- "generator-flight": "0.8.0",
- "grunt": "^0.4.5",
- "grunt-autoprefixer": "2.0.0",
- "grunt-build-control": "0.2.2",
- "grunt-cli": "^0.1.13",
- "grunt-concurrent": "1.0.0",
- "grunt-contrib-clean": "0.6.0",
- "grunt-contrib-coffee": "0.12.0",
- "grunt-contrib-compass": "1.0.1",
- "grunt-contrib-compress": "0.12.0",
- "grunt-contrib-concat": "0.5.0",
- "grunt-contrib-connect": "0.9.0",
- "grunt-contrib-copy": "0.7.0",
- "grunt-contrib-cssmin": "0.10.0",
- "grunt-contrib-handlebars": "^0.8.0",
- "grunt-contrib-htmlmin": "0.3.0",
- "grunt-contrib-imagemin": "0.9.2",
- "grunt-contrib-jshint": "0.10.0",
- "grunt-contrib-requirejs": "~0.4.4",
- "grunt-contrib-uglify": "0.6.0",
- "grunt-contrib-watch": "0.6.1",
- "grunt-google-cdn": "0.4.3",
- "grunt-karma": "0.9.0",
- "grunt-newer": "0.8.0",
- "grunt-ngmin": "0.0.3",
- "grunt-regex-replace": "^0.2.6",
- "grunt-rev": "~0.1.0",
- "grunt-svgmin": "2.0.0",
- "grunt-usemin": "2.6.2",
"handlebars": "2.0.0",
+ "html-minifier": "^0.6.9",
+ "imagemin": "3.1.0",
+ "jshint": "2.5.10",
"jshint-stylish": "1.0.0",
"karma": "0.12.28",
"karma-chrome-launcher": "0.1.7",
"karma-firefox-launcher": "0.1.3",
"karma-jasmine": "0.2.2",
- "karma-junit-reporter": "^0.2.2",
+ "karma-junit-reporter": "0.2.2",
"karma-phantomjs-launcher": "0.1.4",
"karma-requirejs": "0.2.2",
- "karma-safari-launcher": "~0.1.1",
- "load-grunt-tasks": "1.0.0",
- "node-static": "0.7.6",
- "requirejs": "2.1.15",
- "time-grunt": "1.0.0",
- "tiny-lr": "0.1.4"
+ "requirejs": "2.1.15"
},
"scripts": {
- "test": "karma start --single-run --browsers PhantomJS",
- "watch-test": "karma start"
+ "test": "npm run clean && npm run handlebars && node_modules/karma/bin/karma start --single-run --browsers PhantomJS $GRUNT_OPTS",
+ "watch-test": "node_modules/karma/bin/karma start",
+ "handlebars": "handlebars app/templates/**/*.hbs > app/js/generated/hbs/templates.js --namespace=window.Pixelated --root .",
+ "compass": "compass compile",
+ "build": "npm run clean && npm run handlebars && npm run compass",
+ "jshint": "node_modules/.bin/jshint --config=.jshintrc `find app -name '*.js' | grep -v -e 'lib' -e 'bower' -e 'generated'`",
+ "clean": "rm -rf .tmp/ dist/**/* app/js/generated/hbs/* app/css/*",
+ "buildmain": "node_modules/requirejs/bin/r.js -o config/buildoptions.js",
+ "package": "/bin/bash config/package.sh",
+ "imagemin": "node config/imagemin.js",
+ "minify_html": "node_modules/.bin/html-minifier app/index.html --collapse-whitespace | sed 's|<!--usemin_start-->.*<!--usemin_end-->|<script src=\"app.min.js\" type=\"text/javascript\"></script>|' > dist/index.html"
}
}