<commit_before>
    var App = {};

    var camera, scene, renderer, light;

    var polys, planes;

    var score = 0;
    var lives = 10;

    var isMobile = false;
    var isFullScreen = false;

    var paused = false;
    var speedInit = 15;
    var speed = speedInit;
    var horizon = 3000;
    var beta = 0;

    var time = Date.now();

    var velocity = 0;

    var sounds = {};

    window.onload = init;

//	init();

    function init(){

        renderer = new THREE.WebGLRenderer( { antialias: false } );

        renderer.setSize( window.innerWidth, window.innerHeight );

        document.body.appendChild(renderer.domElement);

        renderer.setClearColor(0x000000, 1.0);

        camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, horizon);

        camera.position.y = -500;
        camera.position.z = 20;

        camera.lookAt(new THREE.Vector3(0,0,0));

        scene = new THREE.Scene();
        scene.fog = new THREE.FogExp2( renderer.getClearColor(), 0.0009 );

        hlight = new THREE.HemisphereLight( 0xffffff, 0xffffff, 0.8 );
        hlight.position.set( 0, 500, 0 );
        scene.add( hlight );

        light = new THREE.PointLight(0xffffff);
        light.position.set(-1000,-90,100);
        scene.add(light);

        addPlanes();

        addPolys();

        // initAudio();

        window.addEventListener( 'resize', onWindowResize, false );

        renderer.domElement.addEventListener("touchstart", onTouchStart, false);

        renderer.domElement.addEventListener("touchend", onTouchEnd, false);

        animate();

        pauseGame();

        document.getElementById('score').innerHTML = '
Get the green energy!
';

}

    function initAudio(){

        var soundFiles = {
            'shot'  : 'Game-Shot.mp3',
            'death' : 'Game-Death.mp3',
            'spawn' : 'Game-Spawn.mp3',
            'break' : 'Game-Break.mp3'
        }

        for(var soundName in soundFiles) {
            var a = new Audio( soundFiles[soundName] );
            a.preload = 'auto';
			sounds[soundName] = a;
        }
    }

    function addPlanes(){

        planes = [];
        var planeSegments = 60;

        var plane = new THREE.Mesh(
          new THREE.PlaneGeometry(horizon, horizon, planeSegments, planeSegments),
          new THREE.MeshBasicMaterial({ color:0x00FFFF, wireframe:true, transparent:true })
        );

/*
          var plane = new THREE.SceneUtils.createMultiMaterialObject(
          new THREE.PlaneGeometry(horizon, horizon, planeSegments, planeSegments),
          [new THREE.MeshBasicMaterial({ color:0x000000 }), new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true, wireframeLinewidth: 2} )]
          //new THREE.MeshPhongMaterial( { color: 0xe4e4e4 } )
        );
*/
        plane.position.z = -20;

        planes[0] = plane;

        planes[1] = plane.clone();
        planes[1].position.y = plane.position.y + horizon;

        planes[2] = plane.clone();
        planes[2].position.y = plane.position.y + horizon * 2;

        scene.add(planes[0]);
        scene.add(planes[1]);
        scene.add(planes[2]);

    }

    function addPolys(){

        polys = [];

        var darkMaterial = new THREE.MeshBasicMaterial( { color: 0x000000, transparent: true, opacity: 0.5 } );

        var cube = new THREE.SceneUtils.createMultiMaterialObject(
          new THREE.CubeGeometry(30, 30, 30),
          //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0xCF0505, wireframe: true, wireframeLinewidth: 3} )]
          [new THREE.MeshPhongMaterial( { color: 0xCF0505 } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1} )]
        );

        var tetra = new THREE.SceneUtils.createMultiMaterialObject(
          new THREE.TetrahedronGeometry( 15, 0),
          //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0xF6790B, wireframe: true, wireframeLinewidth: 3} )]
          [new THREE.MeshPhongMaterial( { color: 0xF6790B } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1} )]
        );

        var octa = new THREE.SceneUtils.createMultiMaterialObject(
          new THREE.OctahedronGeometry( 10, 0),
          //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0x17C2EA, wireframe: true, wireframeLinewidth: 3} )]
          [new THREE.MeshPhongMaterial( { color: 0x00FF00 } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1} )]
        );

        // var cone = new THREE.SceneUtils.createMultiMaterialObject(
        //     new THREE.CylinderGeometry( 0, 30, 100, 20, 4 ),
        //     //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0xCDF346, wireframe: true, wireframeLinewidth: 3} )]
        //     [new THREE.MeshPhongMaterial( { color: 0xCDF346 } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1} )]
        //   );

        var cone = new THREE.Mesh(
            new THREE.CylinderGeometry( 50, 50, 800, 20, 4 ),
            //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0xCDF346, wireframe: true, wireframeLinewidth: 3} )]
            //new THREE.MeshPhongMaterial( { color: 0xCDF346, transparent: true, opacity: 0.3} )
            new THREE.MeshPhongMaterial( { color: 0x00FFFF, transparent: true, opacity: 0.3} )

          );

        var isoc = new THREE.SceneUtils.createMultiMaterialObject(
            new THREE.IcosahedronGeometry( 30, 0 ),
             //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0xCC00FF, wireframe: true, wireframeLinewidth: 3} )]
             [new THREE.MeshPhongMaterial( { color: 0xCC00FF } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1} )]
        );

        var totalPolys = 150;

        for(var i = 0; i < totalPolys; i++){
          var poly;
          if(i < (totalPolys * 0.6)){
            poly = octa.clone();
            poly.shape = 'octa';
          } else if(i >= totalPolys * 0.6 && i < totalPolys * 0.9){
            poly = tetra.clone();
            poly.shape = 'tetra';
          } else {
            poly = cube.clone();
            poly.shape = 'cube';
          }

          poly.position.set(Math.random() * horizon - horizon/2, Math.random() * horizon + horizon/2, 20);

          poly.spinX = (Math.random() * 30 - 15) / 1000;
          poly.spinY = (Math.random() * 8 - 4) /100;

          poly.modX = (Math.random() * 20 - 10)/10;
          poly.modY = (Math.random() * 10 - 5)/10;
          polys.push(poly);
          scene.add( poly );
        }

         var poly = isoc.clone();
         poly.shape = 'isoc';

          poly.position.set(Math.random() * horizon - horizon/2, Math.random() * horizon + horizon/2, 20);

          poly.spinX =  (Math.random() * 30 - 15) / 100;
          poly.spinY = (Math.random() * 8 - 4) /10;

          poly.modX = 0;
          poly.modY = 0;
          polys.push(poly);
          scene.add( poly );

        // Cones

        for(var i = 0; i < 12; i++){

          var poly = cone.clone();
          poly.shape = 'cone';

          poly.position.set(Math.random() * horizon - horizon/2, Math.random() * horizon + horizon/2, 380);

          poly.rotation.x = Math.PI /2;

          poly.spinX = 0;
          poly.spinY = 0;
          poly.modX = 0;
          poly.modY = 0;

          polys.push(poly);
          scene.add( poly );

        }

    }

    function render() {
                renderer.render( scene, camera );
    }

    function animate() {

        if (!paused) {

            // -- Polys

            for(var i = 0; i < polys.length; i++){
                var poly = polys[i];
                poly.rotation.x += poly.spinX;
                poly.rotation.y += poly.spinY;
                poly.position.x += poly.modX;
                poly.position.y += - speed  - poly.modY;

                if(poly.position.y < camera.position.y){

                    if(poly.position.x >= camera.position.x -25 && poly.position.x <= camera.position.x +25){

                        if(poly.shape == 'octa'){
                            playSound('shot');
                            score = score + (10 * (speed - speedInit + 1) );
                            updateScore();
                        }
                        if(poly.shape == 'isoc'){
                            playSound('spawn');
                            score = score + (50 * (speedInit - speed + 1) );
                            updateScore();
                        }
                        if(poly.shape == 'tetra'){
                            playSound('break');
                            lives--;
                            updateLives();
                        }
                        if(poly.shape == 'cube'){
                            playSound('break');
                            lives = lives - 2;
                            updateLives();
                        }
                        if(poly.shape == 'cone'){
                            playSound('break');
                            lives = lives - 5;
                            updateLives();
                        }
                    }

                    polys[i].position.x = Math.random() * horizon - horizon/2;
                    polys[i].position.y = horizon;
                }

            }

            // -- Planes

            if(planes[0].position.y < - horizon ){
              planes[0].position.y = planes[2].position.y + horizon;

            }

            if(planes[1].position.y < - horizon ){
              planes[1].position.y = planes[0].position.y + horizon;
            }

            if(planes[2].position.y < - horizon ){
              planes[2].position.y = planes[1].position.y + horizon;
              speed++;
            }

            planes[0].position.y +=- speed ;
            planes[1].position.y +=- speed ;
            planes[2].position.y +=- speed ;

            // -- Camera

            camera.translateX( beta );

            light.position.x = camera.position.x;

            if(camera.position.x > horizon/2){
                camera.position.x = horizon/2;
            }

            if(camera.position.x < -horizon/2){
                camera.position.x = -horizon/2;
            }

            // -- Draw it!

        }

        render();

        window.requestAnimationFrame(animate);

    }

    function updateScore(){

        document.getElementById('score').innerHTML = score;

    }

    function updateLives(){

        document.getElementById('lives').innerHTML = lives;

        if(lives < 1){
            gameOver();
        }

    }

    function pauseGame(){

        if(!paused){
            paused = true;
            //stopSound('music');
        } else {
            paused = false;
            //playSound('music');
            updateScore();
            updateLives();
        }

    }

    function gameOver(){

        playSound('death');

        document.getElementById('score').innerHTML = 'GAME OVER
SCORE: ' + score * 10;

        document.getElementById('lives').innerHTML = '';

        pauseGame();

        score = 0;
        lives = 10;
        speed = speedInit;

    }

    function playSound(sound){
        if(window.Audio){

            //console.log('playing: ' + sound);

            //var snd = document.getElementById(sound);
            var snd = sounds[sound];

            if(!snd){
                return;
            }
            snd.volume = 0.1;

            try {
                snd.pause();
                snd.currentTime = 0;
            } catch (err){}

            snd.play();

        }
    }

    function stopSound(sound){
        if(window.Audio){

           // var snd = document.getElementById(sound);

            var snd = sounds[sound];

            if(!snd){
                return;
            }
            try {
                snd.pause();
                snd.currentTime = 0;
            } catch (err){}

        }
    }

// ---- Events

function onTouchStart(event) {

        if(paused){
            pauseGame();
        }

        touchX = event.touches[0].clientX;

        var percent = touchX / window.innerWidth;

        beta = percent * 90 - 45;

}

function onTouchEnd(event){
    beta = 0;
}

function onWindowResize() {

    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();
    renderer.setSize( window.innerWidth, window.innerHeight );
    render();

}

<commit_msg>Added vibration to game2<commit_after>
    var App = {};

    var camera, scene, renderer, light;

    var polys, planes;

    var score = 0;
    var lives = 10;

    var isMobile = false;
    var isFullScreen = false;

    var hasVibration = false;

    var paused = false;
    var speedInit = 15;
    var speed = speedInit;
    var horizon = 3000;
    var beta = 0;

    var time = Date.now();

    var velocity = 0;

    var sounds = {};

    window.onload = init;

//	init();

    function init(){

        hasVibration = (typeof(window.navigator.vibrate) === 'function');

        renderer = new THREE.WebGLRenderer( { antialias: false } );

        renderer.setSize( window.innerWidth, window.innerHeight );

        document.body.appendChild(renderer.domElement);

        renderer.setClearColor(0x000000, 1.0);

        camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, horizon);

        camera.position.y = -500;
        camera.position.z = 20;

        camera.lookAt(new THREE.Vector3(0,0,0));

        scene = new THREE.Scene();
        scene.fog = new THREE.FogExp2( renderer.getClearColor(), 0.0009 );

        hlight = new THREE.HemisphereLight( 0xffffff, 0xffffff, 0.8 );
        hlight.position.set( 0, 500, 0 );
        scene.add( hlight );

        light = new THREE.PointLight(0xffffff);
        light.position.set(-1000,-90,100);
        scene.add(light);

        addPlanes();

        addPolys();

        // initAudio();

        window.addEventListener( 'resize', onWindowResize, false );

        renderer.domElement.addEventListener("touchstart", onTouchStart, false);

        renderer.domElement.addEventListener("touchend", onTouchEnd, false);

        animate();

        pauseGame();

        document.getElementById('score').innerHTML = '
Get the green energy!
';

}

    function initAudio(){

        var soundFiles = {
            'shot'  : 'Game-Shot.mp3',
            'death' : 'Game-Death.mp3',
            'spawn' : 'Game-Spawn.mp3',
            'break' : 'Game-Break.mp3'
        }

        for(var soundName in soundFiles) {
            var a = new Audio( soundFiles[soundName] );
            a.preload = 'auto';
			sounds[soundName] = a;
        }
    }

    function addPlanes(){

        planes = [];
        var planeSegments = 60;

        var plane = new THREE.Mesh(
          new THREE.PlaneGeometry(horizon, horizon, planeSegments, planeSegments),
          new THREE.MeshBasicMaterial({ color:0x00FFFF, wireframe:true, transparent:true })
        );

/*
          var plane = new THREE.SceneUtils.createMultiMaterialObject(
          new THREE.PlaneGeometry(horizon, horizon, planeSegments, planeSegments),
          [new THREE.MeshBasicMaterial({ color:0x000000 }), new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true, wireframeLinewidth: 2} )]
          //new THREE.MeshPhongMaterial( { color: 0xe4e4e4 } )
        );
*/
        plane.position.z = -20;

        planes[0] = plane;

        planes[1] = plane.clone();
        planes[1].position.y = plane.position.y + horizon;

        planes[2] = plane.clone();
        planes[2].position.y = plane.position.y + horizon * 2;

        scene.add(planes[0]);
        scene.add(planes[1]);
        scene.add(planes[2]);

    }

    function addPolys(){

        polys = [];

        var darkMaterial = new THREE.MeshBasicMaterial( { color: 0x000000, transparent: true, opacity: 0.5 } );

        var cube = new THREE.SceneUtils.createMultiMaterialObject(
          new THREE.CubeGeometry(30, 30, 30),
          //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0xCF0505, wireframe: true, wireframeLinewidth: 3} )]
          [new THREE.MeshPhongMaterial( { color: 0xCF0505 } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1} )]
        );

        var tetra = new THREE.SceneUtils.createMultiMaterialObject(
          new THREE.TetrahedronGeometry( 15, 0),
          //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0xF6790B, wireframe: true, wireframeLinewidth: 3} )]
          [new THREE.MeshPhongMaterial( { color: 0xF6790B } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1} )]
        );

        var octa = new THREE.SceneUtils.createMultiMaterialObject(
          new THREE.OctahedronGeometry( 10, 0),
          //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0x17C2EA, wireframe: true, wireframeLinewidth: 3} )]
          [new THREE.MeshPhongMaterial( { color: 0x00FF00 } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1} )]
        );

        // var cone = new THREE.SceneUtils.createMultiMaterialObject(
        //     new THREE.CylinderGeometry( 0, 30, 100, 20, 4 ),
        //     //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0xCDF346, wireframe: true, wireframeLinewidth: 3} )]
        //     [new THREE.MeshPhongMaterial( { color: 0xCDF346 } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1} )]
        //   );

        var cone = new THREE.Mesh(
            new THREE.CylinderGeometry( 50, 50, 800, 20, 4 ),
            //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0xCDF346, wireframe: true, wireframeLinewidth: 3} )]
            //new THREE.MeshPhongMaterial( { color: 0xCDF346, transparent: true, opacity: 0.3} )
            new THREE.MeshPhongMaterial( { color: 0x00FFFF, transparent: true, opacity: 0.3} )

          );

        var isoc = new THREE.SceneUtils.createMultiMaterialObject(
            new THREE.IcosahedronGeometry( 30, 0 ),
             //[darkMaterial, new THREE.MeshBasicMaterial( { color: 0xCC00FF, wireframe: true, wireframeLinewidth: 3} )]
             [new THREE.MeshPhongMaterial( { color: 0xCC00FF } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1} )]
        );

        var totalPolys = 150;

        for(var i = 0; i < totalPolys; i++){
          var poly;
          if(i < (totalPolys * 0.6)){
            poly = octa.clone();
            poly.shape = 'octa';
          } else if(i >= totalPolys * 0.6 && i < totalPolys * 0.9){
            poly = tetra.clone();
            poly.shape = 'tetra';
          } else {
            poly = cube.clone();
            poly.shape = 'cube';
          }

          poly.position.set(Math.random() * horizon - horizon/2, Math.random() * horizon + horizon/2, 20);

          poly.spinX = (Math.random() * 30 - 15) / 1000;
          poly.spinY = (Math.random() * 8 - 4) /100;

          poly.modX = (Math.random() * 20 - 10)/10;
          poly.modY = (Math.random() * 10 - 5)/10;
          polys.push(poly);
          scene.add( poly );
        }

         var poly = isoc.clone();
         poly.shape = 'isoc';

          poly.position.set(Math.random() * horizon - horizon/2, Math.random() * horizon + horizon/2, 20);

          poly.spinX =  (Math.random() * 30 - 15) / 100;
          poly.spinY = (Math.random() * 8 - 4) /10;

          poly.modX = 0;
          poly.modY = 0;
          polys.push(poly);
          scene.add( poly );

        // Cones

        for(var i = 0; i < 12; i++){

          var poly = cone.clone();
          poly.shape = 'cone';

          poly.position.set(Math.random() * horizon - horizon/2, Math.random() * horizon + horizon/2, 380);

          poly.rotation.x = Math.PI /2;

          poly.spinX = 0;
          poly.spinY = 0;
          poly.modX = 0;
          poly.modY = 0;

          polys.push(poly);
          scene.add( poly );

        }

    }

    function render() {
                renderer.render( scene, camera );
    }

    function animate() {

        if (!paused) {

            // -- Polys

            for(var i = 0; i < polys.length; i++){
                var poly = polys[i];
                poly.rotation.x += poly.spinX;
                poly.rotation.y += poly.spinY;
                poly.position.x += poly.modX;
                poly.position.y += - speed  - poly.modY;

                if(poly.position.y < camera.position.y){

                    if(poly.position.x >= camera.position.x -25 && poly.position.x <= camera.position.x +25){

                        if(poly.shape == 'octa'){
                            playSound('shot');
                            score = score + (10 * (speed - speedInit + 1) );
                            updateScore();
                        }
                        if(poly.shape == 'isoc'){
                            playSound('spawn');
                            score = score + (50 * (speedInit - speed + 1) );
                            updateScore();
                        }
                        if(poly.shape == 'tetra'){
                            bumpShort();
                            playSound('break');
                            lives--;
                            updateLives();
                        }
                        if(poly.shape == 'cube'){
                            bumpMedium();
                            playSound('break');
                            lives = lives - 2;
                            updateLives();
                        }
                        if(poly.shape == 'cone'){
                            bumpLong();
                            playSound('break');
                            lives = lives - 5;
                            updateLives();
                        }
                    }

                    polys[i].position.x = Math.random() * horizon - horizon/2;
                    polys[i].position.y = horizon;
                }

            }

            // -- Planes

            if(planes[0].position.y < - horizon ){
              planes[0].position.y = planes[2].position.y + horizon;

            }

            if(planes[1].position.y < - horizon ){
              planes[1].position.y = planes[0].position.y + horizon;
            }

            if(planes[2].position.y < - horizon ){
              planes[2].position.y = planes[1].position.y + horizon;
              speed++;
            }

            planes[0].position.y +=- speed ;
            planes[1].position.y +=- speed ;
            planes[2].position.y +=- speed ;

            // -- Camera

            camera.translateX( beta );

            light.position.x = camera.position.x;

            if(camera.position.x > horizon/2){
                camera.position.x = horizon/2;
            }

            if(camera.position.x < -horizon/2){
                camera.position.x = -horizon/2;
            }

            // -- Draw it!

        }

        render();

        window.requestAnimationFrame(animate);

    }

    function updateScore(){

        document.getElementById('score').innerHTML = score;

    }

    function updateLives(){

        document.getElementById('lives').innerHTML = lives;

        if(lives < 1){
            gameOver();
        }

    }

    function pauseGame(){

        if(!paused){
            paused = true;
            //stopSound('music');
        } else {
            paused = false;
            //playSound('music');
            updateScore();
            updateLives();
        }

    }

    function gameOver(){

        playSound('death');

        document.getElementById('score').innerHTML = 'GAME OVER
SCORE: ' + score * 10;

        document.getElementById('lives').innerHTML = '';

        pauseGame();

        score = 0;
        lives = 10;
        speed = speedInit;

    }

    function bumpShort() {
       if (hasVibration) {
           window.navigator.vibrate(100);
       }
    }
    function bumpMedium() {
       if (hasVibration) {
           window.navigator.vibrate(200);
       }
    }
    function bumpLong() {
       if (hasVibration) {
           window.navigator.vibrate(500);
       }
    }

    function playSound(sound){
        if(window.Audio){

            //console.log('playing: ' + sound);

            //var snd = document.getElementById(sound);
            var snd = sounds[sound];

            if(!snd){
                return;
            }
            snd.volume = 0.1;

            try {
                snd.pause();
                snd.currentTime = 0;
            } catch (err){}

            snd.play();

        }
    }

    function stopSound(sound){
        if(window.Audio){

           // var snd = document.getElementById(sound);

            var snd = sounds[sound];

            if(!snd){
                return;
            }
            try {
                snd.pause();
                snd.currentTime = 0;
            } catch (err){}

        }
    }

// ---- Events

function onTouchStart(event) {

        if(paused){
            pauseGame();
        }

        touchX = event.touches[0].clientX;

        var percent = touchX / window.innerWidth;

        beta = percent * 90 - 45;

}

function onTouchEnd(event){
    beta = 0;
}

function onWindowResize() {

    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();
    renderer.setSize( window.innerWidth, window.innerHeight );
    render();

}

<|endoftext|>


<commit_before>module.exports = require('sails-generate-entities')({
  module: 'sails-auth',
  id: 'auth-api',
  statics: [
    'api/models/Passport.js',
    'api/models/User.js',
    'api/controllers/AuthController.js',
    'api/controllers/UserController.js',
    'api/services/protocols/index.js',
    'config/routes/sails-auth.js',
    'config/passport.js'
  ],
  classes: [
    'api/services/passport.js',
    'api/services/protocols/local.js',
    'api/services/protocols/oauth.js',
    'api/services/protocols/oauth2.js',
    'api/services/protocols/openid.js'
  ],
  functions: [
    'api/policies/passport.js',
    'api/policies/basicAuth.js',
    'api/policies/sessionAuth.js',
    'api/services/protocols/basic.js'
  ]
});
<commit_msg>remove custom sessionAuth<commit_after>module.exports = require('sails-generate-entities')({
  module: 'sails-auth',
  id: 'auth-api',
  statics: [
    'api/models/Passport.js',
    'api/models/User.js',
    'api/controllers/AuthController.js',
    'api/controllers/UserController.js',
    'api/services/protocols/index.js',
    'config/routes/sails-auth.js',
    'config/passport.js'
  ],
  classes: [
    'api/services/passport.js',
    'api/services/protocols/local.js',
    'api/services/protocols/oauth.js',
    'api/services/protocols/oauth2.js',
    'api/services/protocols/openid.js'
  ],
  functions: [
    'api/policies/passport.js',
    'api/policies/basicAuth.js',
    'api/services/protocols/basic.js'
  ]
});
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');

module.exports = function(grunt) {

  require('load-grunt-tasks')(grunt);

  grunt.initConfig({

    remote: require('./config/remote.json'),

    // Specify where you'd like to keep your files
    app: {
      server: 'server',
      src   : 'client.src',
      dev   : 'client.dev',
      prod  : 'client.prod',
      tmp   : 'tmp',
      bower : 'bower_components'
    },

    clean: {
      dev : ['tmp', '<%= app.dev %>'],
      prod: ['tmp', '<%= app.prod %>']
    },

    jshint: {
      options: {
        jshintrc : '.jshintrc'
      },
      source: {
        src: ['<%= app.src %>/**/*.js']
      }
    },

    jst: {
      templates: {
        options: {
          prettify: true,

          // This converts our file names into camelCase names.
          // For instance, some-name.okay.ext => someNameOkay
          processName: function(filename) {
            var basename = path.basename( filename, path.extname(filename) );
            return basename.replace(/[-\.]([a-z])/g, function (g) { return g[1].toUpperCase(); });
          }
        },
        files: {
          '<%= app.tmp %>/templates.js': ['<%= app.src %>/**/*.jst']
        }
      }
    },

    stylus: {
      options: {
        'include css': true,
        import: ['variables'],
        paths: ['bower_components']
      },
      dev: {
        src: ['<%= app.src %>/core/assets/styl/index.styl', '<%= app.src %>/core/views/**/*.styl', '<%= app.src %>/modules/**/*.styl', '<%= app.src %>/vendor/**/*.styl', '<%= app.src %>/shared/**/*.styl'],
        dest: '<%= app.dev %>/style.css'
      },
      prod: {
        options: {
          compress: true
        },
        src: ['<%= app.src %>/core/assets/styl/index.styl', '<%= app.src %>/cores/views/**/*.styl', '<%= app.src %>/modules/**/*.styl', '<%= app.src %>/vendor/**/*.styl', '<%= app.src %>/shared/**/*.styl'],
        dest: '<%= app.prod %>/style.css'
      },
    },

    cssmin: {
      prod: {
        src: '<%= stylus.prod.dest %>',
        dest: '<%= stylus.prod.dest %>'
      }
    },

    // Only minify images for production. Just copy for dev.
    imagemin: {
      prod: {
        expand: true,
        cwd: '<%= app.src %>/core/assets',
        src: ['img/**/*.{png,jpg}'],
        dest: '<%= app.prod %>'
      }
    },

    copy: {
      favicon_dev: {
        src:  '<%= app.src %>/core/assets/favicon.ico',
        dest: '<%= app.dev %>/favicon.ico'
      },
      favicon_prod: {
        src:  '<%= app.src %>/core/assets/favicon.ico',
        dest: '<%= app.prod %>/favicon.ico'
      },
      images: {
        expand: true,
        flatten: true,
        src:  ['<%= app.src %>/core/assets/img/**/*', '!<%= app.src %>/img/sprite/*'],
        dest: '<%= app.dev %>/img'
      },
      fonts_dev: {
        expand: true,
        flatten: true,
        src: ['<%= app.bower %>/octicons/octicons/*.{ttf,eot,svg,woff}', '<%= app.bower %>/entypo/font/*.{ttf,eot,svg,woff}'],
        dest: '<%= app.dev %>/fonts'
      },
      fonts_prod: {
        expand: true,
        flatten: true,
        src: ['<%= app.bower %>/octicons/octicons/*.{ttf,eot,svg,ttf,woff}', '<%= app.bower %>/entypo/font/*.{ttf,eot,svg,woff}'],
        dest: '<%= app.prod %>/fonts'
      }
    },

    watch: {

      // Refresh the watch task when the Gruntfile changes
      grunt: {
        files: ['gruntfile.js']
      },
      // scripts: {
      //   files: ['<%= app.src %>/**/*.js'],
      //   tasks: ['jshint', 'webpack:dev']
      // },
      styles: {
        files: ['<%= app.src %>/**/*.styl'],
        tasks: ['stylus:dev']
      },
      images: {
        files: ['<%= app.src %>/img/**/*', '!<%= app.src %>/img/sprite/*'],
        tasks: ['copy:images']
      },
      fonts: {
        files: ['<%= app.src %>/fonts/**/*'],
        tasks: ['copy:fonts']
      },
      jst: {
        files: ['<%= app.src %>/**/*.jst'],
        tasks: ['jst', 'webpack:dev']
      },

      // Refresh the browser when clientside code change
      assets: {
        files: '<%= app.dev %>/**/*',
        options: {
          spawn: false,
          livereload: 35729
        }
      },

      // Restart the express app & refresh browser when
      // server-side code changes
      express: {
        options: {
          spawn: false,
          livereload: 35729
        },
        files: '<%= app.server %>/**/*',
        tasks: ['express:dev']
      }
    },

    express: {
      options: {
        script: '<%= app.server %>/app.js',
        output: 'Gistbook is listening on port 3000'
      },
      dev: {
        options: {
          node_env: 'dev',
        }
      }
    },

    webpack: {
      options: {
        entry: './<%= app.src %>/core/index.js',
        module: {
          loaders: [
            {test: /templates/, loader: 'imports?_=underscore!exports?this.JST'},
            {test: /\.js$/, loader: '6to5-loader'},
            // {test: /jquery-mockjax/, loader: 'imports?jQuery=jquery'}
          ]
        },
        resolve: {
          alias: {
            marionette: 'backbone.marionette',
            wreqr: 'backbone.wreqr',
            radio: 'backbone.radio',
            _: 'underscore'
          },
          modulesDirectories: ['node_modules', '<%= app.tmp %>']
        },
        cache: true,
        watch: true
      },
      dev: {
        output: {
          path: './<%= app.dev %>/',
          filename: 'script.js',
          pathinfo: true
        },
        devtool: 'eval-source-map',
        debug: true
      },
      prod: {
        output: {
          path: './client.prod/',
          filename: 'script.js'
        }
      }
    },

    uglify: {
      prod: {
        src: '<%= app.prod %>/script.js',
        dest: '<%= app.prod %>/script.js'
      }
    },

    rsync: {
      server: {
        options: {
          ssh: true,
          args: ['--verbose'],
          exclude: ['.git', '.node_modules', 'node_modules/', '.gitignore', '<%= app.prod %>/', '<%= app.dev %>/', 'bower_components/', '<%= app.tmp %>'],
          recursive: true,
          syncDestIgnoreExcl: true,
          src: ['<%= app.src %>', '.jshintrc', 'bower.json', 'package.json', 'gruntfile.js', 'server', 'config'],
          dest: '<%= remote.dest %>',
          host: '<%= remote.host %>'
        }
      }
    }
  });

  grunt.registerTask('default', 'An alias of test', ['test']);

  grunt.registerTask('test', 'Runs unit tests', ['jshint']);

  grunt.registerTask('build', 'Build the application', function(target) {
    target = target || 'dev';
    var images = (target === 'dev') ? 'copy:images' : 'imagemin';

    var taskArray = [
      'clean:'+target,
      'jst',
      'webpack:'+target,
      'copy:favicon_'+target,
      'copy:fonts_'+target,
      images,
      'stylus:'+target
    ];

    if (target === 'prod') {
      taskArray.push('cssmin:prod', 'uglify:prod');
    }

    grunt.task.run(taskArray);
  });

  grunt.registerTask('work', 'Develop the app', ['jshint', 'build:dev', 'express:dev', 'watch']);

  // For running the site on a production server
  grunt.registerTask('deploy', 'Deploy the app', ['jshint', 'build:prod', 'express:prod']);

};
<commit_msg>Adds exclude pattern for 6to5-loader<commit_after>var path = require('path');
var webpack = require('webpack');

module.exports = function(grunt) {

  require('load-grunt-tasks')(grunt);

  grunt.initConfig({

    remote: require('./config/remote.json'),

    // Specify where you'd like to keep your files
    app: {
      server: 'server',
      src   : 'client.src',
      dev   : 'client.dev',
      prod  : 'client.prod',
      tmp   : 'tmp',
      bower : 'bower_components'
    },

    clean: {
      dev : ['tmp', '<%= app.dev %>'],
      prod: ['tmp', '<%= app.prod %>']
    },

    jshint: {
      options: {
        jshintrc : '.jshintrc'
      },
      source: {
        src: ['<%= app.src %>/**/*.js']
      }
    },

    jst: {
      templates: {
        options: {
          prettify: true,

          // This converts our file names into camelCase names.
          // For instance, some-name.okay.ext => someNameOkay
          processName: function(filename) {
            var basename = path.basename( filename, path.extname(filename) );
            return basename.replace(/[-\.]([a-z])/g, function (g) { return g[1].toUpperCase(); });
          }
        },
        files: {
          '<%= app.tmp %>/templates.js': ['<%= app.src %>/**/*.jst']
        }
      }
    },

    stylus: {
      options: {
        'include css': true,
        import: ['variables'],
        paths: ['bower_components']
      },
      dev: {
        src: ['<%= app.src %>/core/assets/styl/index.styl', '<%= app.src %>/core/views/**/*.styl', '<%= app.src %>/modules/**/*.styl', '<%= app.src %>/vendor/**/*.styl', '<%= app.src %>/shared/**/*.styl'],
        dest: '<%= app.dev %>/style.css'
      },
      prod: {
        options: {
          compress: true
        },
        src: ['<%= app.src %>/core/assets/styl/index.styl', '<%= app.src %>/cores/views/**/*.styl', '<%= app.src %>/modules/**/*.styl', '<%= app.src %>/vendor/**/*.styl', '<%= app.src %>/shared/**/*.styl'],
        dest: '<%= app.prod %>/style.css'
      },
    },

    cssmin: {
      prod: {
        src: '<%= stylus.prod.dest %>',
        dest: '<%= stylus.prod.dest %>'
      }
    },

    // Only minify images for production. Just copy for dev.
    imagemin: {
      prod: {
        expand: true,
        cwd: '<%= app.src %>/core/assets',
        src: ['img/**/*.{png,jpg}'],
        dest: '<%= app.prod %>'
      }
    },

    copy: {
      favicon_dev: {
        src:  '<%= app.src %>/core/assets/favicon.ico',
        dest: '<%= app.dev %>/favicon.ico'
      },
      favicon_prod: {
        src:  '<%= app.src %>/core/assets/favicon.ico',
        dest: '<%= app.prod %>/favicon.ico'
      },
      images: {
        expand: true,
        flatten: true,
        src:  ['<%= app.src %>/core/assets/img/**/*', '!<%= app.src %>/img/sprite/*'],
        dest: '<%= app.dev %>/img'
      },
      fonts_dev: {
        expand: true,
        flatten: true,
        src: ['<%= app.bower %>/octicons/octicons/*.{ttf,eot,svg,woff}', '<%= app.bower %>/entypo/font/*.{ttf,eot,svg,woff}'],
        dest: '<%= app.dev %>/fonts'
      },
      fonts_prod: {
        expand: true,
        flatten: true,
        src: ['<%= app.bower %>/octicons/octicons/*.{ttf,eot,svg,ttf,woff}', '<%= app.bower %>/entypo/font/*.{ttf,eot,svg,woff}'],
        dest: '<%= app.prod %>/fonts'
      }
    },

    watch: {

      // Refresh the watch task when the Gruntfile changes
      grunt: {
        files: ['gruntfile.js']
      },
      // scripts: {
      //   files: ['<%= app.src %>/**/*.js'],
      //   tasks: ['jshint', 'webpack:dev']
      // },
      styles: {
        files: ['<%= app.src %>/**/*.styl'],
        tasks: ['stylus:dev']
      },
      images: {
        files: ['<%= app.src %>/img/**/*', '!<%= app.src %>/img/sprite/*'],
        tasks: ['copy:images']
      },
      fonts: {
        files: ['<%= app.src %>/fonts/**/*'],
        tasks: ['copy:fonts']
      },
      jst: {
        files: ['<%= app.src %>/**/*.jst'],
        tasks: ['jst', 'webpack:dev']
      },

      // Refresh the browser when clientside code change
      assets: {
        files: '<%= app.dev %>/**/*',
        options: {
          spawn: false,
          livereload: 35729
        }
      },

      // Restart the express app & refresh browser when
      // server-side code changes
      express: {
        options: {
          spawn: false,
          livereload: 35729
        },
        files: '<%= app.server %>/**/*',
        tasks: ['express:dev']
      }
    },

    express: {
      options: {
        script: '<%= app.server %>/app.js',
        output: 'Gistbook is listening on port 3000'
      },
      dev: {
        options: {
          node_env: 'dev',
        }
      }
    },

    webpack: {
      options: {
        entry: './<%= app.src %>/core/index.js',
        module: {
          loaders: [
            {test: /templates/, loader: 'imports?_=underscore!exports?this.JST'},
            {test: /\.js$/, exclude: /node_modules/, loader: '6to5-loader'},
            // {test: /jquery-mockjax/, loader: 'imports?jQuery=jquery'}
          ]
        },
        resolve: {
          alias: {
            marionette: 'backbone.marionette',
            wreqr: 'backbone.wreqr',
            radio: 'backbone.radio',
            _: 'underscore'
          },
          modulesDirectories: ['node_modules', '<%= app.tmp %>']
        },
        cache: true,
        watch: true
      },
      dev: {
        output: {
          path: './<%= app.dev %>/',
          filename: 'script.js',
          pathinfo: true
        },
        devtool: 'eval-source-map',
        debug: true
      },
      prod: {
        output: {
          path: './client.prod/',
          filename: 'script.js'
        }
      }
    },

    uglify: {
      prod: {
        src: '<%= app.prod %>/script.js',
        dest: '<%= app.prod %>/script.js'
      }
    },

    rsync: {
      server: {
        options: {
          ssh: true,
          args: ['--verbose'],
          exclude: ['.git', '.node_modules', 'node_modules/', '.gitignore', '<%= app.prod %>/', '<%= app.dev %>/', 'bower_components/', '<%= app.tmp %>'],
          recursive: true,
          syncDestIgnoreExcl: true,
          src: ['<%= app.src %>', '.jshintrc', 'bower.json', 'package.json', 'gruntfile.js', 'server', 'config'],
          dest: '<%= remote.dest %>',
          host: '<%= remote.host %>'
        }
      }
    }
  });

  grunt.registerTask('default', 'An alias of test', ['test']);

  grunt.registerTask('test', 'Runs unit tests', ['jshint']);

  grunt.registerTask('build', 'Build the application', function(target) {
    target = target || 'dev';
    var images = (target === 'dev') ? 'copy:images' : 'imagemin';

    var taskArray = [
      'clean:'+target,
      'jst',
      'webpack:'+target,
      'copy:favicon_'+target,
      'copy:fonts_'+target,
      images,
      'stylus:'+target
    ];

    if (target === 'prod') {
      taskArray.push('cssmin:prod', 'uglify:prod');
    }

    grunt.task.run(taskArray);
  });

  grunt.registerTask('work', 'Develop the app', ['jshint', 'build:dev', 'express:dev', 'watch']);

  // For running the site on a production server
  grunt.registerTask('deploy', 'Deploy the app', ['jshint', 'build:prod', 'express:prod']);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
    var fs=require("fs");
    var pathModule=require("path");

    var filterTypeScriptFiles = function(content, srcPath) {
        var matchRule = /^.*@private/ig;
        if (matchRule.test(content))
        {
            return false;
        }
        var processed = content;
        processed = processed.replace(/\/\/[\/\s]*@private((.|\s)*?)\/\/[\/\s]*@endprivate/gm, "");
        return processed;
    };

    var updatePackageDef = function(content, update)
    {
        var contentAsObject = JSON.parse(content);
        update(contentAsObject);
        return JSON.stringify(contentAsObject, null, "\t");
    }

    var updateModulesPackageDef = function(content, srcPath) {
        return updatePackageDef(content, function(contentAsObject) {
            contentAsObject.version = localCfg.packageVersion;
        });
    };

    var updateAppPackageDef = function(content, srcPath) {
        var currentAppName = grunt.task.current.data.appName;
        return updatePackageDef(content, function(contentAsObject) {
            contentAsObject.version = localCfg.packageVersion;
            contentAsObject.name = "tns-samples-" + currentAppName;
            contentAsObject.description = "Nativescript " + currentAppName + " sample application";
            contentAsObject.license = "BSD";
        });
    };

    var updateDefinitionsPackageDef = function(content, srcPath) {
        return updatePackageDef(content, function(contentAsObject) {
            contentAsObject.version = localCfg.packageVersion;
            contentAsObject.name = "tns-definitions";
            contentAsObject.description = "NativeScript Module definitions";
            contentAsObject.license = "Apache-2.0";
        });
    }

    var getPackageVersion = function(packageFilePath) {
        packageContent = grunt.file.readJSON(packageFilePath);
        var buildVersion = process.env.PACKAGE_VERSION;
        if (!buildVersion) {
            return packageContent.version;
        }
        return packageContent.version + "-" + buildVersion;
    };

    var processAppFile = function(content, srcPath) {
        return content;
    };

    var getSubDirs = function(dir) {
        var allObjects = fs.readdirSync(dir);
        var allDirs = [];
        for (var i=0; i<allObjects.length; i++)
        {
            var currentObjName = allObjects[i];
            var currentObjPath = pathModule.join(dir, currentObjName);
            var stats = fs.statSync(currentObjPath);
            if (stats.isDirectory())
            {
                allDirs.push({name: currentObjName, path: currentObjPath});
            }
        }
        return allDirs;
    }

    var localCfg = {
        srcDir: ".",
        srcAppsDir: "./apps",
        packageJsonFilePath: "./package.json",
        outDir: "./bin/dist",
        outModulesDir: "./bin/dist/modules",
        outAppsDir: "./bin/dist/apps",
        outTsAppsDir: "./bin/dist/ts-apps",
        outDefinitionsDir: "./bin/dist/definitions",

        excludedModules: [
            "!./ui/slide-out/**/*.*"
        ]
    };
    localCfg.packageVersion = getPackageVersion(localCfg.packageJsonFilePath);
    localCfg.defaultExcludes = [
            "!" + localCfg.outDir + "/**/*.*",
            "!./node_modules/**/*.*",
            "!./bin/**/*.*",
            "!./build/**/*.*",
            "!./Deploy/**/*.*",
            "!./obj/**/*.*",
            "!./out/**/*.*",
            "!./.*/**/*.*"
        ];
    localCfg.typeScriptSrc = [
            "./**/*.ts"
        ].concat(localCfg.defaultExcludes).concat(localCfg.excludedModules);
    localCfg.typeScriptSrcForTsLint = localCfg.typeScriptSrc.concat([
        "!./ios.d.ts",
        "!./android17.d.ts",
        "!./libjs.d.ts"
    ]);

    grunt.initConfig({
        localCfg : localCfg,
        pkg: grunt.file.readJSON('package.json'),
        clean: {
            build: {
                src: [localCfg.outDir]
            },
            typeScriptLeftovers: {
                expand: true,
                src: [
                    "./.baseDir.*",
                    "./_references.js",
                    "./**/*.map"
                ],
                cwd: localCfg.outModulesDir
            },
            readyAppFiles: {
                src: [localCfg.outModulesDir + "/apps/**"]
            }
        },
        copy: {
            jsLibs: {
                expand: true,
                src: [
                    "./js-libs/**/*.js",
                ],
                dest: "<%= localCfg.outModulesDir %>/",
                cwd: localCfg.srcDir
            },
            license: {
                expand: true,
                src: [
                    "./LICENSE",
                ],
                dest: "<%= localCfg.outModulesDir %>/",
                cwd: localCfg.srcDir
            },
            appLicense: {
                expand: true,
                src: ["./LICENSE"],
                cwd: localCfg.srcAppsDir,
                dest: "__dummy__"
            },
            definitionFiles: {
                src: [
                    localCfg.srcDir + "/**/*.d.ts",
                    //Exclude the d.ts files in the apps folder - these are part of the apps and are already packed there!
                    "!" + localCfg.srcDir + "/apps/**"
                ].concat(localCfg.defaultExcludes).concat(localCfg.excludedModules),
                dest: localCfg.outDefinitionsDir + "/",
                options: {
                    process: filterTypeScriptFiles
                }
            },
            modulesPackageDef: {
                src: localCfg.packageJsonFilePath,
                dest: localCfg.outModulesDir + "/",
                options: {
                    process: updateModulesPackageDef
                }
            },
            definitionsPackageDef: {
                src: localCfg.packageJsonFilePath,
                dest: localCfg.outDefinitionsDir + "/",
                options: {
                    process: updateDefinitionsPackageDef
                }
            },
            appPackageDef: {
                expand: true,
                flatten: true,
                src: "__app_package_json",
                dest:  "__dummy__",
                options: {
                    process: updateAppPackageDef
                }
            },
            childPackageFiles: {
                src: [
                    localCfg.srcDir + "/**/package.json",
                    "!./package.json",
                    "!./Deploy/**/*.*",
                    "!./bin/**/*.*",
                    "!./Tests/**/*.*",
                    "!" + localCfg.outDir + "/**/*.*"
                ].concat(localCfg.excludedModules),
                dest: localCfg.outModulesDir + "/"
            },
            rawAppsFiles: {
                expand: true,
                src: [
                    "**/*.*",
                    "**/*",
                    "!**/*.map",
                    "!**/*.ts"
                ],
                dest: localCfg.outAppsDir,
                cwd: localCfg.srcAppsDir,
                dot: true
            },
            readyAppFiles: {
                expand: true,
                src: ["./**/*.*"],
                dest: localCfg.outAppsDir + "/",
                cwd: localCfg.outModulesDir + "/apps/",
                options: {
                    process: processAppFile
                }
            },
            readyTsAppFiles: {
                expand: true,
                src: ["./**/*.*", "!./**/*.map"],
                dest: localCfg.outTsAppsDir + "/",
                cwd: localCfg.srcAppsDir
            },
            readyPackages: {
                expand: true,
                src: ["./**/*.tgz"],
                dest: localCfg.outDir + "/",
                cwd: localCfg.outDir,
                flatten: true
            }
        },
        ts: {
            build: {
                src: localCfg.typeScriptSrc,
                outDir: [localCfg.outModulesDir],
                options: {
                    module: "commonjs",
                    target: "es5",
                    sourceMap: false,
                    declaration: false,
                    removeComments: "<%= !grunt.option('leavecomments') || '' %>",
                    compiler: "node_modules/typescript/bin/tsc"
                }
            }
        },
        tslint: {
            build: {
                files: {
                    src: localCfg.typeScriptSrcForTsLint
                },
                options: {
                    configuration: grunt.file.readJSON("./build/tslint.json")
                }
            }
        },
        exec: {
            packModules: {
                cmd: "npm pack",
                cwd: localCfg.outModulesDir + "/"
            },
            packDefinitions: {
                cmd: "npm pack",
                cwd: localCfg.outDefinitionsDir + "/"
            },
            packApp: {
                cmd: "npm pack",
                cwd: "__dummy__"
            }
        },
        multidest: {
            copyLicenseFiles: {
                tasks: ["copy:appLicense"],
                dest: function() {
                    var apps = getSubDirs(localCfg.srcAppsDir);
                    var targetDirs = [];
                    apps.forEach(function(item){
                        targetDirs.push(pathModule.join(localCfg.outAppsDir, item.name));
                        targetDirs.push(pathModule.join(localCfg.outTsAppsDir, item.name));
                    });
                    return targetDirs;
                }()
            }
        }
    });

    grunt.loadNpmTasks("grunt-ts");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-exec");
    grunt.loadNpmTasks("grunt-tslint");
    grunt.loadNpmTasks("grunt-multi-dest");

    var cloneTasks = function(originalTasks, taskNameSuffix)
    {
        var clonedTasks = [];
        for(var i=0; i<originalTasks.length; i++)
        {
            var originalTask = originalTasks[i];

            var taskCfg = grunt.util._.clone(grunt.config(originalTask.name));
            var taskName = grunt.util._.clone(originalTask.name);
            taskName[1] = taskName[1] + "_" + taskNameSuffix;

            originalTask.specializeCfg(taskCfg, taskNameSuffix);

            clonedTasks.push({name: taskName, cfg: taskCfg});
        }
        return clonedTasks;
    }

    var enqueueTasks = function(tasks) {
        for (var i=0; i<tasks.length; i++) {
            var task = tasks[i];
            grunt.config(task.name, task.cfg);
            grunt.task.run(task.name.join(":"));
        }
    }

    grunt.registerTask("processEachApp", function(outAppsDir, pkgAppNameSuffix){
        var allapps = getSubDirs(localCfg.srcAppsDir);
        var tasks = [
            {
                name: ["copy", "appPackageDef"],
                specializeCfg: function (cfg, currentAppName) {
                    outAppDir = pathModule.join(outAppsDir, currentAppName);
                    var pkgFilePath = pathModule.join(outAppDir, "package.json");
                    cfg.src = pkgFilePath;
                    cfg.dest = outAppDir;
                    cfg.appName = currentApp.name + (pkgAppNameSuffix || "");
                }
            },
            {
                name: ["exec", "packApp"],
                specializeCfg: function(cfg, currentAppName) {
                    cfg.cwd = pathModule.join(outAppsDir, currentAppName);
                }
            }
        ];

        for (var j=0; j<allapps.length; j++)
        {
            var currentApp = allapps[j];
            var clonedTasks = cloneTasks(tasks, currentApp.name);

            enqueueTasks(clonedTasks);
        }
    });

    grunt.registerTask("tests", [
        "default"
    ]);

    grunt.registerTask("collect-apps-raw-files", [
        "copy:rawAppsFiles",
        "multidest:copyLicenseFiles"
    ]);

    // Does nothing to avoid copying the same files twice. Instead,
    //  the distribute-definition-files tasks copies the d.ts files
    //  from the source root directly to the output folder.
    grunt.registerTask("collect-definitions-raw-files", []);

    grunt.registerTask("collect-modules-raw-files", [
        "copy:jsLibs",
        "copy:license"
    ]);

    grunt.registerTask("compile-ts", [
        "ts:build",
        "clean:typeScriptLeftovers",
        "copy:childPackageFiles"
    ]);
    grunt.registerTask("distribute-apps-files", [
        "copy:readyAppFiles",
        "clean:readyAppFiles"
    ]);
    grunt.registerTask("distribute-ts-apps-files", [
        "copy:readyTsAppFiles"
    ]);
    grunt.registerTask("distribute-definition-files", [
        "copy:definitionFiles"
    ]);
    grunt.registerTask("pack-modules", [
        "copy:modulesPackageDef",
        "exec:packModules"
    ]);
    grunt.registerTask("pack-apps", [
        "processEachApp:" + localCfg.outAppsDir
    ]);
    grunt.registerTask("pack-ts-apps", [
        "processEachApp:" + localCfg.outTsAppsDir + ":-ts"
    ]);
    grunt.registerTask("pack-definitions", [
        "copy:definitionsPackageDef",
        "exec:packDefinitions"
    ]);
    grunt.registerTask("get-ready-packages", [
        "copy:readyPackages"
    ]);

    grunt.registerTask("default", ((typeof(grunt.option('runtslint')) != "undefined" && !grunt.option('runtslint')) ? [] : ["tslint:build"]).concat([
        "clean:build",

        "collect-apps-raw-files",
        "collect-definitions-raw-files",
        "collect-modules-raw-files",

        "compile-ts",
        "distribute-apps-files",
        "distribute-ts-apps-files",
        "distribute-definition-files",

        "pack-modules",
        "pack-apps",
        "pack-ts-apps",
        "pack-definitions",
        "get-ready-packages"
    ]));
};
<commit_msg>Collect the modules-license for the definitions package<commit_after>module.exports = function(grunt) {
    var fs=require("fs");
    var pathModule=require("path");

    var filterTypeScriptFiles = function(content, srcPath) {
        var matchRule = /^.*@private/ig;
        if (matchRule.test(content))
        {
            return false;
        }
        var processed = content;
        processed = processed.replace(/\/\/[\/\s]*@private((.|\s)*?)\/\/[\/\s]*@endprivate/gm, "");
        return processed;
    };

    var updatePackageDef = function(content, update)
    {
        var contentAsObject = JSON.parse(content);
        update(contentAsObject);
        return JSON.stringify(contentAsObject, null, "\t");
    }

    var updateModulesPackageDef = function(content, srcPath) {
        return updatePackageDef(content, function(contentAsObject) {
            contentAsObject.version = localCfg.packageVersion;
        });
    };

    var updateAppPackageDef = function(content, srcPath) {
        var currentAppName = grunt.task.current.data.appName;
        return updatePackageDef(content, function(contentAsObject) {
            contentAsObject.version = localCfg.packageVersion;
            contentAsObject.name = "tns-samples-" + currentAppName;
            contentAsObject.description = "Nativescript " + currentAppName + " sample application";
            contentAsObject.license = "BSD";
        });
    };

    var updateDefinitionsPackageDef = function(content, srcPath) {
        return updatePackageDef(content, function(contentAsObject) {
            contentAsObject.version = localCfg.packageVersion;
            contentAsObject.name = "tns-definitions";
            contentAsObject.description = "NativeScript Module definitions";
            contentAsObject.license = "Apache-2.0";
        });
    }

    var getPackageVersion = function(packageFilePath) {
        packageContent = grunt.file.readJSON(packageFilePath);
        var buildVersion = process.env.PACKAGE_VERSION;
        if (!buildVersion) {
            return packageContent.version;
        }
        return packageContent.version + "-" + buildVersion;
    };

    var processAppFile = function(content, srcPath) {
        return content;
    };

    var getSubDirs = function(dir) {
        var allObjects = fs.readdirSync(dir);
        var allDirs = [];
        for (var i=0; i<allObjects.length; i++)
        {
            var currentObjName = allObjects[i];
            var currentObjPath = pathModule.join(dir, currentObjName);
            var stats = fs.statSync(currentObjPath);
            if (stats.isDirectory())
            {
                allDirs.push({name: currentObjName, path: currentObjPath});
            }
        }
        return allDirs;
    }

    var localCfg = {
        srcDir: ".",
        srcAppsDir: "./apps",
        packageJsonFilePath: "./package.json",
        outDir: "./bin/dist",
        outModulesDir: "./bin/dist/modules",
        outAppsDir: "./bin/dist/apps",
        outTsAppsDir: "./bin/dist/ts-apps",
        outDefinitionsDir: "./bin/dist/definitions",

        excludedModules: [
            "!./ui/slide-out/**/*.*"
        ]
    };
    localCfg.packageVersion = getPackageVersion(localCfg.packageJsonFilePath);
    localCfg.defaultExcludes = [
            "!" + localCfg.outDir + "/**/*.*",
            "!./node_modules/**/*.*",
            "!./bin/**/*.*",
            "!./build/**/*.*",
            "!./Deploy/**/*.*",
            "!./obj/**/*.*",
            "!./out/**/*.*",
            "!./.*/**/*.*"
        ];
    localCfg.typeScriptSrc = [
            "./**/*.ts"
        ].concat(localCfg.defaultExcludes).concat(localCfg.excludedModules);
    localCfg.typeScriptSrcForTsLint = localCfg.typeScriptSrc.concat([
        "!./ios.d.ts",
        "!./android17.d.ts",
        "!./libjs.d.ts"
    ]);

    grunt.initConfig({
        localCfg : localCfg,
        pkg: grunt.file.readJSON('package.json'),
        clean: {
            build: {
                src: [localCfg.outDir]
            },
            typeScriptLeftovers: {
                expand: true,
                src: [
                    "./.baseDir.*",
                    "./_references.js",
                    "./**/*.map"
                ],
                cwd: localCfg.outModulesDir
            },
            readyAppFiles: {
                src: [localCfg.outModulesDir + "/apps/**"]
            }
        },
        copy: {
            jsLibs: {
                expand: true,
                src: [
                    "./js-libs/**/*.js",
                ],
                dest: "<%= localCfg.outModulesDir %>/",
                cwd: localCfg.srcDir
            },
            license: {
                expand: true,
                src: [
                    "./LICENSE",
                ],
                dest: "<%= localCfg.outModulesDir %>/",
                cwd: localCfg.srcDir
            },
            appLicense: {
                expand: true,
                src: ["./LICENSE"],
                cwd: localCfg.srcAppsDir,
                dest: "__dummy__"
            },
            definitionFiles: {
                src: [
                    localCfg.srcDir + "/**/*.d.ts",
                    pathModule.join(localCfg.srcDir, "LICENSE"),
                    //Exclude the d.ts files in the apps folder - these are part of the apps and are already packed there!
                    "!" + localCfg.srcDir + "/apps/**"
                ].concat(localCfg.defaultExcludes).concat(localCfg.excludedModules),
                dest: localCfg.outDefinitionsDir + "/",
                options: {
                    process: filterTypeScriptFiles
                }
            },
            modulesPackageDef: {
                src: localCfg.packageJsonFilePath,
                dest: localCfg.outModulesDir + "/",
                options: {
                    process: updateModulesPackageDef
                }
            },
            definitionsPackageDef: {
                src: localCfg.packageJsonFilePath,
                dest: localCfg.outDefinitionsDir + "/",
                options: {
                    process: updateDefinitionsPackageDef
                }
            },
            appPackageDef: {
                expand: true,
                flatten: true,
                src: "__app_package_json",
                dest:  "__dummy__",
                options: {
                    process: updateAppPackageDef
                }
            },
            childPackageFiles: {
                src: [
                    localCfg.srcDir + "/**/package.json",
                    "!./package.json",
                    "!./Deploy/**/*.*",
                    "!./bin/**/*.*",
                    "!./Tests/**/*.*",
                    "!" + localCfg.outDir + "/**/*.*"
                ].concat(localCfg.excludedModules),
                dest: localCfg.outModulesDir + "/"
            },
            rawAppsFiles: {
                expand: true,
                src: [
                    "**/*.*",
                    "**/*",
                    "!**/*.map",
                    "!**/*.ts"
                ],
                dest: localCfg.outAppsDir,
                cwd: localCfg.srcAppsDir,
                dot: true
            },
            readyAppFiles: {
                expand: true,
                src: ["./**/*.*"],
                dest: localCfg.outAppsDir + "/",
                cwd: localCfg.outModulesDir + "/apps/",
                options: {
                    process: processAppFile
                }
            },
            readyTsAppFiles: {
                expand: true,
                src: ["./**/*.*", "!./**/*.map"],
                dest: localCfg.outTsAppsDir + "/",
                cwd: localCfg.srcAppsDir
            },
            readyPackages: {
                expand: true,
                src: ["./**/*.tgz"],
                dest: localCfg.outDir + "/",
                cwd: localCfg.outDir,
                flatten: true
            }
        },
        ts: {
            build: {
                src: localCfg.typeScriptSrc,
                outDir: [localCfg.outModulesDir],
                options: {
                    module: "commonjs",
                    target: "es5",
                    sourceMap: false,
                    declaration: false,
                    removeComments: "<%= !grunt.option('leavecomments') || '' %>",
                    compiler: "node_modules/typescript/bin/tsc"
                }
            }
        },
        tslint: {
            build: {
                files: {
                    src: localCfg.typeScriptSrcForTsLint
                },
                options: {
                    configuration: grunt.file.readJSON("./build/tslint.json")
                }
            }
        },
        exec: {
            packModules: {
                cmd: "npm pack",
                cwd: localCfg.outModulesDir + "/"
            },
            packDefinitions: {
                cmd: "npm pack",
                cwd: localCfg.outDefinitionsDir + "/"
            },
            packApp: {
                cmd: "npm pack",
                cwd: "__dummy__"
            }
        },
        multidest: {
            copyLicenseFiles: {
                tasks: ["copy:appLicense"],
                dest: function() {
                    var apps = getSubDirs(localCfg.srcAppsDir);
                    var targetDirs = [];
                    apps.forEach(function(item){
                        targetDirs.push(pathModule.join(localCfg.outAppsDir, item.name));
                        targetDirs.push(pathModule.join(localCfg.outTsAppsDir, item.name));
                    });
                    return targetDirs;
                }()
            }
        }
    });

    grunt.loadNpmTasks("grunt-ts");
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-copy");
    grunt.loadNpmTasks("grunt-exec");
    grunt.loadNpmTasks("grunt-tslint");
    grunt.loadNpmTasks("grunt-multi-dest");

    var cloneTasks = function(originalTasks, taskNameSuffix)
    {
        var clonedTasks = [];
        for(var i=0; i<originalTasks.length; i++)
        {
            var originalTask = originalTasks[i];

            var taskCfg = grunt.util._.clone(grunt.config(originalTask.name));
            var taskName = grunt.util._.clone(originalTask.name);
            taskName[1] = taskName[1] + "_" + taskNameSuffix;

            originalTask.specializeCfg(taskCfg, taskNameSuffix);

            clonedTasks.push({name: taskName, cfg: taskCfg});
        }
        return clonedTasks;
    }

    var enqueueTasks = function(tasks) {
        for (var i=0; i<tasks.length; i++) {
            var task = tasks[i];
            grunt.config(task.name, task.cfg);
            grunt.task.run(task.name.join(":"));
        }
    }

    grunt.registerTask("processEachApp", function(outAppsDir, pkgAppNameSuffix){
        var allapps = getSubDirs(localCfg.srcAppsDir);
        var tasks = [
            {
                name: ["copy", "appPackageDef"],
                specializeCfg: function (cfg, currentAppName) {
                    outAppDir = pathModule.join(outAppsDir, currentAppName);
                    var pkgFilePath = pathModule.join(outAppDir, "package.json");
                    cfg.src = pkgFilePath;
                    cfg.dest = outAppDir;
                    cfg.appName = currentApp.name + (pkgAppNameSuffix || "");
                }
            },
            {
                name: ["exec", "packApp"],
                specializeCfg: function(cfg, currentAppName) {
                    cfg.cwd = pathModule.join(outAppsDir, currentAppName);
                }
            }
        ];

        for (var j=0; j<allapps.length; j++)
        {
            var currentApp = allapps[j];
            var clonedTasks = cloneTasks(tasks, currentApp.name);

            enqueueTasks(clonedTasks);
        }
    });

    grunt.registerTask("tests", [
        "default"
    ]);

    grunt.registerTask("collect-apps-raw-files", [
        "copy:rawAppsFiles",
        "multidest:copyLicenseFiles"
    ]);

    // Does nothing to avoid copying the same files twice. Instead,
    //  the distribute-definition-files tasks copies the d.ts files
    //  from the source root directly to the output folder.
    grunt.registerTask("collect-definitions-raw-files", []);

    grunt.registerTask("collect-modules-raw-files", [
        "copy:jsLibs",
        "copy:license"
    ]);

    grunt.registerTask("compile-ts", [
        "ts:build",
        "clean:typeScriptLeftovers",
        "copy:childPackageFiles"
    ]);
    grunt.registerTask("distribute-apps-files", [
        "copy:readyAppFiles",
        "clean:readyAppFiles"
    ]);
    grunt.registerTask("distribute-ts-apps-files", [
        "copy:readyTsAppFiles"
    ]);
    grunt.registerTask("distribute-definition-files", [
        "copy:definitionFiles"
    ]);
    grunt.registerTask("pack-modules", [
        "copy:modulesPackageDef",
        "exec:packModules"
    ]);
    grunt.registerTask("pack-apps", [
        "processEachApp:" + localCfg.outAppsDir
    ]);
    grunt.registerTask("pack-ts-apps", [
        "processEachApp:" + localCfg.outTsAppsDir + ":-ts"
    ]);
    grunt.registerTask("pack-definitions", [
        "copy:definitionsPackageDef",
        "exec:packDefinitions"
    ]);
    grunt.registerTask("get-ready-packages", [
        "copy:readyPackages"
    ]);

    grunt.registerTask("default", ((typeof(grunt.option('runtslint')) != "undefined" && !grunt.option('runtslint')) ? [] : ["tslint:build"]).concat([
        "clean:build",

        "collect-apps-raw-files",
        "collect-definitions-raw-files",
        "collect-modules-raw-files",

        "compile-ts",
        "distribute-apps-files",
        "distribute-ts-apps-files",
        "distribute-definition-files",

        "pack-modules",
        "pack-apps",
        "pack-ts-apps",
        "pack-definitions",
        "get-ready-packages"
    ]));
};
<|endoftext|>


<commit_before>module.exports = function(grunt) { // Grunt wrapper - Do grunt-related things in here

  grunt.initConfig({ // Initialize our configuration object
    pkg: grunt.file.readJSON('package.json'), // Read project settings from package.json

    //Set a path for the app folder.
    // The benifit of doing this is that when it comes time to start plugging in a cms we can just alter this to point to a new folder, for example the wordpress theme folder.
    path: 'app',

    // DANGER ZONE! BE CAREFUL!
    // This cleans the destination folder out completely.
    // This shouldn't matter if you are using the correct Bread and Butter workflow and only working in the src folder but only you and the lord above know if that is the case.
    clean: ['<%= path %>/**/*', '<%= path %>/.htaccess'],

    copy: {

      pages: {
        // This copies the pages from the src/pages folder to the app folder
        files: [
          {
            expand: true,
            cwd: 'src/pages/',
            src: ['*.php', '*.html', '.htaccess'],
            dest: '<%= path %>/'
          }
        ]
      },

      modules: {
        // This copies the modules from the src/modules folder to the app/modules folder
        files: [
          {
            expand: true,
            cwd: 'src/modules/',
            src: ['*.php'],
            dest: '<%= path %>/modules/'
          }
        ]
      },

      includes: {
        // This copies the includes from the src/includes folder to the app/includes folder
        files: [
          {
            expand: true,
            cwd: 'src/includes/',
            src: ['*.php'],
            dest: '<%= path %>/includes/'
          }
        ]
      },

      images: {
        // This copies the includes from the src/images folder to the app/images folder
        files: [
          {
            expand: true,
            cwd: 'src/images/',
            src: ['*.jpg', '*.png', '*.gif'],
            dest: '<%= path %>/images/'
          }
        ]
      },

      fontcopy:{
      // This task will find the relevant font files in the src/fonts folder and move them to the app/fonts folder.
        files: [
          {
            expand: true,
            cwd: 'src/fonts/',
            src: ['**/*.eot', '**/*.svg', '**/*.ttf', '**/*.woff'],
            dest: '<%= path %>/fonts/'
          }
        ]
      }
    },

    uglify: {

      // The base uglify task
      base: {
        options: {
          mangle: false,
          // If you want to add banners to your minified css uncomment the below. This currently is commented out in order to clean up commits in development.
          // banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
        },
        files: {
        '<%= path %>/js/custom.min.js': ['src/js/custom.js']
        }
      },

    },

    jshint: {

      // The jshint task.
      files: [
      'src/js/custom.js', // Just watch the src js file not the minified one
      ]
    },

    less: {

      // Configure the less task
      // The compilation of our css goes through three stages:
      // 1. We use this less task to compile the less to css in the src folder
      // 2. We use the auto-prefixer task to put prefixes for various browsers into our css file and move it to the app folder
      // 3. We use the cssmin task to minify that css file into a new file with the .min.css extension

      // So here we go...
      // 1. We use this less task to compile the less to css in the src folder
      development: {
        options: {
          paths: ["src/less"],
        },
        files: {
          // target.css file: source.less file
          "src/css/style.css": "src/less/style.less"
        }
      }
    },

    autoprefixer: {

      // We use the auto-prefixer task to put prefixes for various browsers into our css file and move it to the app folder
      options: {
        browsers: ['last 3 versions'] // More options available for this see https://github.com/ai/autoprefixer#browsers
      },
      files: {
        src: 'src/css/style.css',
        dest: '<%= path %>/style.css' // Put the autoprefixed version right back over its original
      }
    },

    cssmin: {

      // We use the cssmin task to minify that css file into a new file with the .min.css extension
      minify: {
        options: {
          // If you want to add banners to your minified css uncomment the below. This currently is commented out in order to clean up commits in development.
          // banner: '/* <%= pkg.name %>.css minified <%= grunt.template.today("dd-mm-yyyy") %> */' // Give it a nice banner
        },
        files: {
          '<%= path %>/style.min.css': ['<%= path %>/style.css']
        }
      },

      // This task will find the stylesheet in the webkit folder, minify it and move it to the app folder
      fontmin: {
        files: [
          {
            expand: true,
            cwd: 'src/fonts/',
            src: ['**/*/stylesheet.css'],
            dest: '<%= path %>/fonts/',
            ext: '.min.css'
          }
        ]
      }
    },

    pixrem: {

      // We run pixrem on that file to create fallback for our use of rem units. We rewrite the result over itself.
      options: {
        rootvalue: '62.5%' // We set this so that the 1 rem unit equals 10px. Easier to understand.
      },
      dist: {
        src: '<%= path %>/style.min.css',
        dest: '<%= path %>/style.min.css'
      }
    },

    watch: {
    // Configure the watch task
    // You should adapt this to your specific needs on a per project basis
      pages: {
        files: ['src/pages/*.php'],
        tasks: ['copy:pages'],
      },
      modules: {
        files: ['src/modules/*.php'],
        tasks: ['copy:modules'],
      },
      includes: {
        files: ['src/includes/*.php'],
        tasks: ['copy:includes'],
      },
      images: {
        files: ['src/images/*'],
        tasks: ['copy:images'],
      },
      scripts: {
        files: ['<%= jshint.files %>'],
        tasks: ['jshint'],
      },
      uglify: {
        files: ['src/**/*.js'],
        tasks: ['uglify'],
      },
      css: {
        files: ['src/**/*.less'],
        tasks: ['less', 'autoprefixer', 'cssmin:minify'],
      },
      css: {
        files: ['src/**/*.less'],
        tasks: ['pixrem'],
      },
      livereload: {
        // Here we watch the files the watch task will change.
        // These files are then sent to the live reload server.
        options: { livereload: true },
        files: ['<%= path %>/**/*'],
      },
    }

  });

    // Load the tasks
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-pixrem');
    grunt.loadNpmTasks('grunt-usemin');

    // Register a test task for jshint. This can be run just by typing "grunt test" on the command line
    grunt.registerTask('test', ['jshint'])

    //Register a task for setting up the webkit fonts when picking up the project
    grunt.registerTask('fontload', ['copy:fontcopy', 'cssmin:fontmin'])

    // And register the default task. This can be run just by typing "grunt" on the command line. This should be done before production.
    grunt.registerTask('default', ['copy:pages', 'copy:modules', 'copy:includes', 'copy:images', 'uglify', 'less', 'autoprefixer', 'cssmin', 'pixrem']);

};<commit_msg>update configurable paths when running grunt tasks<commit_after>module.exports = function(grunt) { // Grunt wrapper - Do grunt-related things in here

  // Set a path for the app and build folder.
  // The benifit of doing this is that when it comes time to start plugging in a cms we can just alter this to point to a new folder, for example the wordpress theme folder.
  var config = {
    app: 'app',
    dist: 'dist'
  };

  grunt.initConfig({ // Initialize our configuration object

    // Project settings
    config: config,

    pkg: grunt.file.readJSON('package.json'), // Read project settings from package.json

    // DANGER ZONE! BE CAREFUL!
    // This cleans the destination folder out completely.
    // This shouldn't matter if you are using the correct Bread and Butter workflow and only working in the src folder but only you and the lord above know if that is the case.
    clean: ['<%= config.app %>/**/*', '<%= config.app %>/.htaccess'],

    copy: {

      pages: {
        // This copies the pages from the src/pages folder to the app folder
        files: [
          {
            expand: true,
            cwd: 'src/pages/',
            src: ['*.php', '*.html', '.htaccess'],
            dest: '<%= config.app %>/'
          }
        ]
      },

      modules: {
        // This copies the modules from the src/modules folder to the app/modules folder
        files: [
          {
            expand: true,
            cwd: 'src/modules/',
            src: ['*.php'],
            dest: '<%= config.app %>/modules/'
          }
        ]
      },

      includes: {
        // This copies the includes from the src/includes folder to the app/includes folder
        files: [
          {
            expand: true,
            cwd: 'src/includes/',
            src: ['*.php'],
            dest: '<%= config.app %>/includes/'
          }
        ]
      },

      images: {
        // This copies the includes from the src/images folder to the app/images folder
        files: [
          {
            expand: true,
            cwd: 'src/images/',
            src: ['*.jpg', '*.png', '*.gif'],
            dest: '<%= config.app %>/images/'
          }
        ]
      },

      fontcopy:{
      // This task will find the relevant font files in the src/fonts folder and move them to the app/fonts folder.
        files: [
          {
            expand: true,
            cwd: 'src/fonts/',
            src: ['**/*.eot', '**/*.svg', '**/*.ttf', '**/*.woff'],
            dest: '<%= config.app %>/fonts/'
          }
        ]
      }
    },

    uglify: {

      // The base uglify task
      base: {
        options: {
          mangle: false,
          // If you want to add banners to your minified css uncomment the below. This currently is commented out in order to clean up commits in development.
          // banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
        },
        files: {
        '<%= config.app %>/js/custom.min.js': ['src/js/custom.js']
        }
      },

    },

    jshint: {

      // The jshint task.
      files: [
      'src/js/custom.js', // Just watch the src js file not the minified one
      ]
    },

    less: {

      // Configure the less task
      // The compilation of our css goes through three stages:
      // 1. We use this less task to compile the less to css in the src folder
      // 2. We use the auto-prefixer task to put prefixes for various browsers into our css file and move it to the app folder
      // 3. We use the cssmin task to minify that css file into a new file with the .min.css extension

      // So here we go...
      // 1. We use this less task to compile the less to css in the src folder
      development: {
        options: {
          paths: ["src/less"],
        },
        files: {
          // target.css file: source.less file
          "src/css/style.css": "src/less/style.less"
        }
      }
    },

    autoprefixer: {

      // We use the auto-prefixer task to put prefixes for various browsers into our css file and move it to the app folder
      options: {
        browsers: ['last 3 versions'] // More options available for this see https://github.com/ai/autoprefixer#browsers
      },
      files: {
        src: 'src/css/style.css',
        dest: '<%= config.app %>/style.css' // Put the autoprefixed version right back over its original
      }
    },

    cssmin: {

      // We use the cssmin task to minify that css file into a new file with the .min.css extension
      minify: {
        options: {
          // If you want to add banners to your minified css uncomment the below. This currently is commented out in order to clean up commits in development.
          // banner: '/* <%= pkg.name %>.css minified <%= grunt.template.today("dd-mm-yyyy") %> */' // Give it a nice banner
        },
        files: {
          '<%= config.app %>/style.min.css': ['<%= config.app %>/style.css']
        }
      },

      // This task will find the stylesheet in the webkit folder, minify it and move it to the app folder
      fontmin: {
        files: [
          {
            expand: true,
            cwd: 'src/fonts/',
            src: ['**/*/stylesheet.css'],
            dest: '<%= config.app %>/fonts/',
            ext: '.min.css'
          }
        ]
      }
    },

    pixrem: {

      // We run pixrem on that file to create fallback for our use of rem units. We rewrite the result over itself.
      options: {
        rootvalue: '62.5%' // We set this so that the 1 rem unit equals 10px. Easier to understand.
      },
      dist: {
        src: '<%= config.app %>/style.min.css',
        dest: '<%= config.app %>/style.min.css'
      }
    },

    watch: {
    // Configure the watch task
    // You should adapt this to your specific needs on a per project basis
      pages: {
        files: ['src/pages/*.php'],
        tasks: ['copy:pages'],
      },
      modules: {
        files: ['src/modules/*.php'],
        tasks: ['copy:modules'],
      },
      includes: {
        files: ['src/includes/*.php'],
        tasks: ['copy:includes'],
      },
      images: {
        files: ['src/images/*'],
        tasks: ['copy:images'],
      },
      scripts: {
        files: ['<%= jshint.files %>'],
        tasks: ['jshint'],
      },
      uglify: {
        files: ['src/**/*.js'],
        tasks: ['uglify'],
      },
      css: {
        files: ['src/**/*.less'],
        tasks: ['less', 'autoprefixer', 'cssmin:minify'],
      },
      css: {
        files: ['src/**/*.less'],
        tasks: ['pixrem'],
      },
      livereload: {
        // Here we watch the files the watch task will change.
        // These files are then sent to the live reload server.
        options: { livereload: true },
        files: ['<%= config.app %>/**/*'],
      },
    }

  });

    // Load the tasks
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-pixrem');
    grunt.loadNpmTasks('grunt-usemin');

    // Register a test task for jshint. This can be run just by typing "grunt test" on the command line
    grunt.registerTask('test', [
      'jshint'
    ]);

    //Register a task for setting up the webkit fonts when picking up the project
    grunt.registerTask('fontload', [
      'copy:fontcopy',
      'cssmin:fontmin'
    ]);

    // And register the default task. This can be run just by typing "grunt" on the command line. This should be done before production.
    grunt.registerTask('default', [
      'copy:pages',
      'copy:modules',
      'copy:includes',
      'copy:images',
      'uglify',
      'less',
      'autoprefixer',
      'cssmin',
      'pixrem'
    ]);

};<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {
    var path = require('path');
    var shell = require('shelljs');

    var bin = ['node_modules', '.bin'].join(path.sep);

    var lsc = [bin, 'lsc'].join(path.sep);
    var npm = 'npm';

    grunt.registerTask('livescript_src', 'update LiveScript source', function () {
        var done = this.async();
        // FIXME: Compile changed file only
        shell.exec(lsc + ' -c lib');
        shell.exec(lsc + ' -c test');
        grunt.task.run('test');
        done();
    });

    grunt.registerTask('package_ls', 'update package.ls', function () {
        var done = this.async();
        shell.exec(lsc + ' -cj package.ls');
        shell.exec(npm + ' install');
        done();
    });

    grunt.registerTask('test', 'run test', function () {
        var done = this.async();
        shell.exec(npm + ' test');
        done();
    });

    grunt.initConfig({
        watch: {
            livescript_src: {
                files: ['lib/**/*.ls', 'test/**/*.ls'],
                tasks: ['livescript_src']
            },
            package_ls: {
                files: ['package.ls'],
                tasks: ['package_ls']
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', ['watch']);
};
<commit_msg>Growl when updating package.ls complated<commit_after>'use strict';

module.exports = function(grunt) {
    var growl = require('growl');
    var path = require('path');
    var shell = require('shelljs');

    var bin = ['node_modules', '.bin'].join(path.sep);

    var lsc = [bin, 'lsc'].join(path.sep);
    var npm = 'npm';

    grunt.registerTask('livescript_src', 'update LiveScript source', function () {
        var done = this.async();
        // FIXME: Compile changed file only
        shell.exec(lsc + ' -c lib');
        shell.exec(lsc + ' -c test');
        grunt.task.run('test');
        done();
    });

    grunt.registerTask('package_ls', 'update package.ls', function () {
        var done = this.async();
        shell.exec(lsc + ' -cj package.ls');
        shell.exec(npm + ' install');
        growl('Update package.ls', { title: 'Completed' });
        done();
    });

    grunt.registerTask('test', 'run test', function () {
        var done = this.async();
        shell.exec(npm + ' test');
        done();
    });

    grunt.initConfig({
        watch: {
            livescript_src: {
                files: ['lib/**/*.ls', 'test/**/*.ls'],
                tasks: ['livescript_src']
            },
            package_ls: {
                files: ['package.ls'],
                tasks: ['package_ls']
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.registerTask('default', ['watch']);
};
<|endoftext|>