Improve grunt tasks

pull/14080/head
rubenmoya 6 years ago
parent 8e69244b6d
commit 7faaa50b1b

@ -2,7 +2,7 @@ The development tracker for CartoDB is on GitHub:
http://github.com/cartodb/cartodb
Bug fixes are best reported as pull requests over there.
Features are best discussed on the mailing list:
Features are best discussed on the mailing list:
https://groups.google.com/d/forum/cartodb
---
@ -39,22 +39,19 @@ The frontend is really standalone code, but is integrated with/served by the Rai
## CSS
We use [SASS](http://sass-lang.com/), with [.scss](http://www.thesassway.com/editorial/sass-vs-scss-which-syntax-is-better) format, which are located at ```app/assets/stylesheets```. [Grunt](http://gruntjs.com/) is used to compile the files into ```.css``` files, instead of the default Sprockets pipeline that Rails provide.
We use [SASS](http://sass-lang.com/), with [.scss](http://www.thesassway.com/editorial/sass-vs-scss-which-syntax-is-better) format, which are located at ```assets/stylesheets```. [Webpack](https://webpack.js.org/) is used to compile the files into ```.css``` files.
See [doc/frontend/README.md](doc/frontend/README.md) for more in-depth documentation.
Also CartoDB makes use of a linter machine for checking possible errors in those stylesheets.
Rules are specified in the [scss-style.yml](scss-style.yml) file. Once a new Pull Request is started,
[Hound](https://houndci.com/) application will check those SCSS changes for warnings.
Also CARTO makes use of a linter machine for checking possible errors in those stylesheets. Rules are specified in the [scss-style.yml](.stylelintrc) file.
## JS
CartoDB is built on top of [CARTO.js](https://github.com/CartoDB/carto.js),
which in turns depends on some common libraries, in particular worth mentioning:
CARTO is built on top of [CARTO.js](https://github.com/CartoDB/carto.js), which in turns depends on some common libraries, in particular worth mentioning:
- [BackboneJS 0.9.2](https://cdn.rawgit.com/jashkenas/backbone/0.9.2/index.html).
- [jQuery 1.7.2](http://api.jquery.com/category/version/1.7/)
- [underscore.js 1.4.4](https://cdn.rawgit.com/jashkenas/underscore/1.4.4/index.html)
- [BackboneJS 1.2.3](https://cdn.rawgit.com/jashkenas/backbone/1.2.3/index.html).
- [jQuery 2.1.4](https://api.jquery.com/category/version/1.12-2.2/)
- [Underscore.js 1.8.3](https://cdn.rawgit.com/jashkenas/underscore/1.8.3/index.html)
Source code is located at `lib/assets/javascripts`, dependencies at `vendor/assets/javascripts`.
@ -76,8 +73,7 @@ Follow these steps to update to get latest changes:
### Writing & running tests
We use
- [Jasmine 2.1](jasmine.github.io/2.1/introduction.html) as test framework
- [SinonJS 1.3.4](sinonjs.org) for test spies/stubs/mocks when Jasmine spies isn't good enough
- [Jasmine 2.5.2](jasmine.github.io/2.5/introduction.html) as test framework
There are two test suites: one for the old Editor and one for Builder.
@ -153,24 +149,21 @@ If you want to run simultaneously the application and the specs generation follo
If you only want to run a subset of tests the easiest and fastest way is to use [focused specs](jasmine.github.io/2.1/focused_specs.html), but you can also append `?spec=str-matching-a-describe` to test URL, or use [--filter flag](https://github.com/gruntjs/grunt-contrib-jasmine#filtering-specs) if running tests in a terminal.
## Grunt
## Running the project
We use [Grunt](http://gruntjs.com/) to automate build tasks related to both CSS and JS.
We use [Webpack](https://webpack.js.org/) to automate build tasks related to both CSS and JS.
We use v6.9.2 of [node](http://nodejs.org/) (we recommend to use [NVM](https://github.com/creationix/nvm)).
Install dependencies using a normal npm install as such:
```bash
npm install
npm install -g grunt-cli
```
Run `grunt availabletasks` to see available tasks.
First time starting to work you need to run `grunt dev`, to build all necessary frontend assets (will be written to `public/assets/:version`).
Then you can run the project with:
```bash
grunt dev
npm start
```
That enables CSS and JS watchers for rebuilding bundles automatically upon changes.
@ -185,6 +178,8 @@ That enables CSS and JS watchers for rebuilding bundles automatically upon chang
_Don't forget to restart Rails after you have modified `config/app_config.yml`._
See [doc/frontend/README.md](doc/frontend/README.md) for more in-depth documentation.
## Building static pages
There are some views that can be served from a static file in `public/static/` directory and must be built beforehand. For that purpose run the following command:

@ -265,15 +265,11 @@ module.exports = function (grunt) {
}
});
// TODO: migrate mixins to postcss
grunt.registerTask('css', [
'copy:vendor',
'copy:app',
'copy:css_cartodb',
'compass',
'copy:css_vendor_builder',
'copy:css_builder',
'copy:css_dashboard',
'sass',
'concat:css'
]);
@ -320,42 +316,30 @@ module.exports = function (grunt) {
'config'
]);
grunt.registerTask('pre', [
grunt.registerTask('dev-editor', [
'beforeDefault',
'js_editor',
'css',
'manifest'
]);
registerCmdTask('npm-dev', {cmd: 'npm', args: ['run', 'dev']});
registerCmdTask('npm-start', {cmd: 'npm', args: ['run', 'start']});
registerCmdTask('npm-build', {cmd: 'npm', args: ['run', 'build']});
registerCmdTask('npm-build-dashboard', {cmd: 'npm', args: ['run', 'build:dashboard']});
registerCmdTask('npm-build-static', {cmd: 'npm', args: ['run', 'build:static']});
registerCmdTask('npm-carto-node', {cmd: 'npm', args: ['run', 'carto-node']});
registerCmdTask('npm-dashboard', {cmd: 'npm', args: ['run', 'dashboard']});
/**
* `grunt dev`
*/
grunt.registerTask('dev', [
'npm-carto-node',
'pre',
'npm-build-dashboard',
grunt.registerTask('editor', [
'dev-editor',
'npm-start'
]);
grunt.registerTask('dashboard', [
'beforeDefault',
'css',
'manifest',
'npm-dashboard'
]);
grunt.registerTask('default', [
'pre',
'npm-dev'
'dev-editor',
'npm-start'
]);
grunt.registerTask('lint', [
@ -371,15 +355,18 @@ module.exports = function (grunt) {
'uglify'
]);
grunt.registerTask('build', [
'npm-carto-node',
// 'pre',
// 'copy:js',
// 'exorcise',
// 'uglify',
'npm-build',
// -- BUILD TASKS
grunt.registerTask('build', 'build editor, builder, dashboard and static pages', [
'build-editor',
'build-static',
'npm-build-dashboard'
'npm-build'
]);
grunt.registerTask('build-editor', 'generate editor css and javasript files', [
'dev-editor',
'exorcise',
'uglify'
]);
grunt.registerTask('build-static', 'generate static files and needed vendor scripts', [

@ -181,19 +181,13 @@
"update-internal-deps": "rm -rf node_modules && npm install --production --no-optional --no-shrinkwrap && npm dedupe && npm prune && npm shrinkwrap && npm run fix-shrinkwrap-protocol && npm install",
"branch-files": "node lib/build/branchFiles/branchFiles.js",
"affected_specs": "node lib/build/branchFiles/branchFiles.js | xargs node lib/build/affectedFiles/affectedFiles.js",
"build": "NODE_ENV='production' webpack --progress --config webpack/builder/webpack.prod.config.js",
"build:all": "NODE_ENV='production' webpack --progress --config webpack/v4/webpack.prod.config.js",
"build:dashboard": "NODE_ENV='production' webpack --progress --config webpack/dashboard/webpack.prod.config.js",
"build": "NODE_ENV='production' webpack --progress --config webpack/v4/webpack.prod.config.js",
"build:static": "NODE_ENV='production' webpack --progress --config webpack/webpack.prod.config.js",
"carto-node": "NODE_ENV=production webpack --progress --config webpack/carto-node/webpack.config.js",
"build:stats": "webpack --env.stats --progress --config webpack.dev.config.js",
"start": "grunt watch:css & webpack --progress --watch --config webpack/builder/webpack.dev.config.js",
"dashboard": "grunt watch:css & webpack --progress --watch --config webpack/dashboard/webpack.dev.config.js",
"webpack:dashboard": "webpack --progress --watch --config webpack/dashboard/webpack.dev.config.js",
"webpack:builder": "webpack --progress --watch --config webpack/builder/webpack.dev.config.js",
"webpack:all": "webpack --progress --watch --config webpack/v4/webpack.dev.config.js",
"start:static": "webpack --progress --watch --config webpack/webpack.dev.config.js",
"dev": "webpack --progress --config webpack/builder/webpack.dev.config.js",
"start": "npm run carto-node && npm run build:static && npm run dev",
"dev": "webpack --progress --watch --config webpack/v4/webpack.dev.config.js",
"dev:static": "webpack --progress --watch --config webpack/webpack.dev.config.js",
"fix-shrinkwrap-protocol": "node ./lib/build/fix-shrinkwrap.js"
}
}

Loading…
Cancel
Save