From 560b7f71774aeadfbd30b66e03061f8b6088fa02 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 15 Jun 2016 12:08:11 +0100 Subject: [PATCH] grunt will auto recompile client and less now, run concurrently --- services/web/Gruntfile.coffee | 112 ++++++++++++++++++++++------------ services/web/package.json | 11 ++-- 2 files changed, 79 insertions(+), 44 deletions(-) diff --git a/services/web/Gruntfile.coffee b/services/web/Gruntfile.coffee index d069c5bac9..2541d719d9 100644 --- a/services/web/Gruntfile.coffee +++ b/services/web/Gruntfile.coffee @@ -7,18 +7,42 @@ module.exports = (grunt) -> grunt.loadNpmTasks 'grunt-mocha-test' grunt.loadNpmTasks 'grunt-available-tasks' grunt.loadNpmTasks 'grunt-contrib-requirejs' - grunt.loadNpmTasks 'grunt-execute' grunt.loadNpmTasks 'grunt-bunyan' grunt.loadNpmTasks 'grunt-sed' grunt.loadNpmTasks 'grunt-git-rev-parse' grunt.loadNpmTasks 'grunt-file-append' grunt.loadNpmTasks 'grunt-file-append' grunt.loadNpmTasks 'grunt-env' + grunt.loadNpmTasks 'grunt-newer' + grunt.loadNpmTasks 'grunt-contrib-watch' + grunt.loadNpmTasks 'grunt-parallel' + grunt.loadNpmTasks 'grunt-exec' config = - execute: - app: - src: "app.js" + + exec: + run: + command:"node app.js | ./node_modules/logger-sharelatex/node_modules/bunyan/bin/bunyan --color" + + + watch: + coffee: + files: '**/*.coffee' + tasks: ['quickcompile:coffee'] + options: {} + + less: + files: '**/*.less' + tasks: ['compile:css'] + options: {} + + + parallel: + run: + tasks:['exec', 'watch'] + options: + grunt:true + stream:true coffee: app_dir: @@ -89,6 +113,8 @@ module.exports = (grunt) -> add: NODE_TLS_REJECT_UNAUTHORIZED:0 + + requirejs: compile: options: @@ -170,44 +196,46 @@ module.exports = (grunt) -> pattern: "@@RELEASE@@" replacement: process.env.BUILD_NUMBER || "(unknown build)" + + availabletasks: tasks: options: - filter: 'exclude', - tasks: [ - 'coffee' - 'less' - 'clean' - 'mochaTest' - 'availabletasks' - 'wrap_sharejs' - 'requirejs' - 'execute' - 'bunyan' - ] - groups: - "Compile tasks": [ - "compile:server" - "compile:client" - "compile:tests" - "compile" - "compile:unit_tests" - "compile:smoke_tests" - "compile:css" - "compile:minify" - "install" - ] - "Test tasks": [ - "test:unit" - "test:acceptance" - ] - "Run tasks": [ - "run" - "default" - ] - "Misc": [ - "help" - ] + filter: 'exclude', + tasks: [ + 'coffee' + 'less' + 'clean' + 'mochaTest' + 'availabletasks' + 'wrap_sharejs' + 'requirejs' + 'execute' + 'bunyan' + ] + groups: + "Compile tasks": [ + "compile:server" + "compile:client" + "compile:tests" + "compile" + "compile:unit_tests" + "compile:smoke_tests" + "compile:css" + "compile:minify" + "install" + ] + "Test tasks": [ + "test:unit" + "test:acceptance" + ] + "Run tasks": [ + "run" + "default" + ] + "Misc": [ + "help" + ] moduleCompileServerTasks = [] moduleCompileUnitTestTasks = [] @@ -310,6 +338,8 @@ module.exports = (grunt) -> grunt.registerTask 'compile:smoke_tests', 'Compile the smoke tests', ['coffee:smoke_tests'] grunt.registerTask 'compile:tests', 'Compile all the tests', ['compile:smoke_tests', 'compile:unit_tests'] grunt.registerTask 'compile', 'Compiles everything need to run web-sharelatex', ['compile:server', 'compile:client', 'compile:css'] + grunt.registerTask 'quickcompile:coffee', 'Compiles only changed coffee files',['newer:coffee'] + grunt.registerTask 'install', "Compile everything when installing as an npm module", ['compile'] @@ -319,11 +349,13 @@ module.exports = (grunt) -> grunt.registerTask 'test:modules:unit', 'Run the unit tests for the modules', ['compile:modules:server', 'compile:modules:unit_tests'].concat(moduleUnitTestTasks) - grunt.registerTask 'run', "Compile and run the web-sharelatex server", ['compile', 'bunyan', 'env:run', 'execute'] + grunt.registerTask 'run', "Compile and run the web-sharelatex server", ['compile', 'env:run', 'parallel'] + grunt.registerTask 'default', 'run' grunt.registerTask 'version', "Write the version number into sentry.jade", ['git-rev-parse', 'sed'] + grunt.registerTask 'create-admin-user', "Create a user with the given email address and make them an admin. Update in place if the user already exists", () -> done = @async() email = grunt.option("email") diff --git a/services/web/package.json b/services/web/package.json index 71070cfe0e..19c057c976 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -67,19 +67,22 @@ "chai-spies": "", "grunt-available-tasks": "0.4.1", "grunt-bunyan": "0.5.0", - "grunt-concurrent": "0.4.3", "grunt-contrib-clean": "0.5.0", "grunt-contrib-coffee": "0.10.0", "grunt-contrib-less": "0.9.0", "grunt-contrib-requirejs": "0.4.1", - "grunt-execute": "0.1.5", + "grunt-contrib-watch": "^1.0.0", + "grunt-env": "0.4.4", + "grunt-exec": "^0.4.7", + "grunt-parallel": "^0.5.1", + "grunt-file-append": "0.0.6", "grunt-git-rev-parse": "^0.1.4", "grunt-mocha-test": "0.9.0", + "grunt-newer": "^1.2.0", "grunt-sed": "^0.1.1", "sandboxed-module": "0.2.0", "sinon": "", - "timekeeper": "", - "grunt-env": "0.4.4" + "timekeeper": "" } }