Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Automatizarea proceselor cu Grunt

Automatizarea proceselor cu Grunt

A short presentation why and how to use automation, on the client side.

Andrei Pfeiffer

October 09, 2013

Transcript

25 slides
  1. Solutii automatizare The Javascript Build Tool for Node.js Flexibil; Setup

    mai lent; The Javascript Task Runner Out-of-the-box; Setup rapid;
  2. De ce automatizare? ➔ Set complet de unit-teste; ➔ Refactorizare;

    ➔ Build dezvoltare: compilare resurse; ➔ Build productie: compactare resurse; ➔ Verificare calitate cod; ➔ Documentatie; ➔ Similar cu un proces “batch”;
  3. De ce Grunt? ➔ Setup rapid; ➔ Curba rapida de

    invatare; ➔ Multe plugin-uri disponibile; http://gruntjs.com/plugins ➔ Popular;
  4. Pas 1: nodejs + npm ➔ Windows & Mac (via

    installer) http://nodejs.org/download/ ➔ Linux (via package manager) https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
  5. Pas 2: package.json ➔ Definim proprietatile proiectului; ➔ Definim pachetele

    necesare; ➔ Se stocheaza in root-ul proiectului; ➔ https://npmjs.org/doc/json.html
  6. Pas 2: package.json { “name”: “proiect demo”, “version”: “0.1”, “description”:

    “lorem ipsum”, “devDependencies”: { “grunt”: “0.4.1”, “grunt-contrib-jshint”: “>=0.6.0”, “grunt-contrib-qunit”: “*” } }
  7. Pas 3: npm install npm install ➔ Rulare din root

    folder (unde e si package.json); ➔ Instalare locala; ➔ Se va crea folderul “node_modules”; ➔ Adaugat in .gitignore; ➔ Nu instalati global dependintele;
  8. Pas 4: grunt cli npm install -g grunt-cli ➔ Instalare

    globala; ➔ Rulare “grunt” de oriunde; ➔ Acces din linia de comanda;
  9. Pas 5: Gruntfile.js ➔ Configurarea proceselor; ➔ Se stocheaza in

    root-ul proiectului; ➔ http://gruntjs.com/sample-gruntfile
  10. Pas 5: Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ jshint: {

    files: ['src/*.js'] } }); grunt.loadNpmTasks('grunt-contrib-jshint'); };
  11. Pas 5: Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ jshint: {

    files: ['src/*.js'] } }); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.registerTask('default', ['jshint']); };
  12. Pas 5: Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ jshint: {

    files: ['src/*.js'] } }); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.registerTask('default', ['jshint']); };
  13. Pas 5: Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ jshint: {

    files: ['src/*.js'] }, qunit: { all: ['test/*.html'] } }); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-qunit'); grunt.registerTask('default', ['jshint', 'qunit']); };
  14. Concluzii 1. Scrii o data, rulezi oricand; 2. Rulare manuala

    sau automata; 3. Testare regresiva; 4. Refactorizare mult usurata; 5. Cod calitativ;

More Decks by Andrei Pfeiffer

Other Decks in Programming