diff --git a/Gruntfile.js b/Gruntfile.js index ef7444cbbb..119c736017 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -19,16 +19,15 @@ * along with EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ -module.exports = function (grunt) { + /** + * * `grunt` - full build + * * `grunt dev` - build only items needed for development + * * `grunt offline` - skips *composer install* + * * `grant release` - full build plus upgrade packages` + * * `grant tests` - build and run tests + */ - var runComposerInstall = false; - if (process.argv.length > 1) { - for (var i in process.argv) { - if (process.argv[i] === '--ci') { - runComposerInstall = true; - } - } - } +module.exports = function (grunt) { var jsFilesToMinify = [ 'client/lib/jquery-2.1.4.min.js', @@ -95,10 +94,6 @@ module.exports = function (grunt) { var fs = require('fs'); var cp = require('child_process'); - if (runComposerInstall) { - cp.execSync("composer install", {stdio: 'ignore'}); - } - var themeList = []; fs.readdirSync('application/Espo/Resources/metadata/themes').forEach(function (file) { themeList.push(file.substr(0, file.length - 5)); @@ -286,6 +281,23 @@ module.exports = function (grunt) { } }); + grunt.registerTask("composer", function() { + cp.execSync("composer install", {stdio: 'ignore'}); + }); + + grunt.registerTask("upgrade", function() { + cp.execSync("node diff --all --vendor", {stdio: 'inherit'}); + }); + + + grunt.registerTask("unitTests", function() { + cp.execSync("phpunit --bootstrap=vendor/autoload.php tests/unit", {stdio: 'inherit'}); + }); + + grunt.registerTask("integrationTests", function() { + cp.execSync("phpunit --bootstrap=vendor/autoload.php tests/integration", {stdio: 'inherit'}); + }); + grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-mkdir'); grunt.loadNpmTasks('grunt-contrib-less'); @@ -296,7 +308,7 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-compress'); grunt.loadNpmTasks('grunt-chmod'); - grunt.registerTask('default', [ + grunt.registerTask('offline', [ 'clean:start', 'mkdir:tmp', 'less', @@ -311,4 +323,25 @@ module.exports = function (grunt) { 'chmod', 'clean:final', ]); + + grunt.registerTask('default', [ + 'composer', + 'offline', + ]); + + grunt.registerTask('release', [ + 'default', + 'upgrade', + ]); + + grunt.registerTask('tests', [ + 'default', + 'unitTests', + 'integrationTests', + ]); + + grunt.registerTask('dev', [ + 'composer', + 'less', + ]); }; diff --git a/README.md b/README.md index 1905ff31ba..2c742a02f9 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Create an issue [here](https://github.com/espocrm/espocrm/issues) or post on our [Download](https://www.espocrm.com/download/) the latest version. See the [instructions](https://www.espocrm.com/documentation/administration/installation/) about installation. -### How to get started (for developers) +### Getting started (for developers) 1. Clone repository to your local computer. 2. Change to the project's root directory. @@ -48,7 +48,9 @@ You need to have nodejs and Grunt CLI installed. The build will be created in the `build` directory. -### How to contribute +Upgrade packages can be built with `grunt upgrade`. + +### How to contribute (for developers) Before we can merge your pull request you need to accept our CLA [here](https://github.com/espocrm/cla). It's very simple to do. @@ -58,6 +60,22 @@ Branches: * master – develop branch; new features should be pushed to this branch; * stable – last stable release. +### Running tests (for developers) + +You need to have *phpunit* installed. + +Unit tests: + +``` +phpunit --bootstrap=vendor/autoload.php tests/unit +``` + +Integration tests: + +``` +phpunit --bootstrap=vendor/autoload.php tests/integration +``` + ### How to make a translation Build po file with command: