<commit_before>/* jshint mocha: true, expr: true, strict: false, undef: false */

describe('test suite', function () {
  it('should assert true', function () {
    true.should.be.true;
    false.should.be.false;
  });
});//end test suite

describe('banishFriend', function () {
  it('should delete the person from the view', function () {
    //do stuff here
  });
});//end banishFriend

describe('getData', function () {
  it('should getData from firebase', function () {
    //do stuff here
  });
});//end getData

describe('loadFriend', function () {
  it('should put a div in the view', function () {
    //do stuff here
    //$('#target').empty();
    var data = {
      name: "Mary",
      phone: "555-555-5555",
      email: "mary@aol.com",
      twitter: "@mary",
      photoURL: "http://i.imgur.com/L6wjzi7.jpg"
    };
    var uuid = '-JhlvtoxluCmZfaDs0fD';
    //run it!
    var friends = loadFriend(uuid, data);
    expect(friends.length).to.equal(1);

  });
});//end loadFriend

describe('makeFriendDiv', function () {
  it('should make a div with a class of "tableBody"', function () {
    var data = {
      name: "Mary",
      phone: "555-555-5555",
      email: "mary@aol.com",
      twitter: "@mary",
      photoURL: "http://i.imgur.com/L6wjzi7.jpg"
    };
    var uuid = 'JhlvtoxluCmZfaDs0fD';
    //i have to run it
    makeFriendDiv(uuid, data);
    expect(".tableBody").to.exist;
    //expect it to have a data-uuid attribute equal to uuid
    //expect($(".tableBody").attr(data-uuid)).to.equal(uuid);
    //expect it to have 6 children
    //expect($(".tablebody").children().length).to.equal('6');
  });
});//end makeFriendDiv

//isn't reading on preventDefault()... issue pass it an event!?!
//test that it grabs the info... issue clears at the end
//test that it sends the info
//test that it clears the info
// describe('sendForm', function () {
//   it('should clear the values of the input fields', function(){
//     $('#name').val('bob');
//     $('#phone').val('555-555-5555');
//     $('#email').val('bob@aol.com');
//     $('#twitter').val('@bob');
//     $('#photo').val('http:imgur.com/bob');
//     sendForm({originalEvent: MouseEvent, type: "click"});
//     expect('#name').val().to.equal(' ');
//   });
// });

describe('stringifyInputValues', function () {
  it('should produce a json string', function () {
    //do stuff here
  });
});//end stringifyInputValues

// describe('showForm', function () {
//   it('should give a style attribute of "display: block" to the form', function () {
//     //same issue as above accessing the style attribute of undefined!! b/c it is a jquery object??
//   })
// })

// describe('hideForm', function () {
//   it('should give a style attribute of "display: none" to the form', function () {
//     //style='display:none'
//     hideForm();
//     var displayAttr = document.querySelector('#contactForm').style;
//     expect(displayAttr).to.equal('none');
//   });
// });
<commit_msg>fixed children length test on makeFriend Div<commit_after>/* jshint mocha: true, expr: true, strict: false, undef: false */

describe('test suite', function () {
  it('should assert true', function () {
    true.should.be.true;
    false.should.be.false;
  });
});//end test suite

describe('banishFriend', function () {
  it('should delete the person from the view', function () {
    //do stuff here
  });
});//end banishFriend

describe('getData', function () {
  it('should getData from firebase', function () {
    //do stuff here
  });
});//end getData

describe('loadFriend', function () {
  it('should put a div in the view', function () {
    //do stuff here
    //$('#target').empty();
    var data = {
      name: "Mary",
      phone: "555-555-5555",
      email: "mary@aol.com",
      twitter: "@mary",
      photoURL: "http://i.imgur.com/L6wjzi7.jpg"
    };
    var uuid = '-JhlvtoxluCmZfaDs0fD';
    //run it!
    var friends = loadFriend(uuid, data);
    expect(friends.length).to.equal(1);

  });
});//end loadFriend

describe('makeFriendDiv', function () {
  it('should make a div with a class of "tableBody"', function () {
    var data = {
      name: "Mary",
      phone: "555-555-5555",
      email: "mary@aol.com",
      twitter: "@mary",
      photoURL: "http://i.imgur.com/L6wjzi7.jpg"
    };
    var uuid = 'JhlvtoxluCmZfaDs0fD';
    //i have to run it
    var friendDiv = makeFriendDiv(uuid, data);
    expect(friendDiv).to.exist;
    //expect it to have a data-uuid attribute equal to uuid
    //expect(friendDiv.attr(data-uuid)).to.equal(uuid);
    //expect it to have 6 children
    expect(friendDiv.children().length).to.equal(6);
  });
});//end makeFriendDiv

//isn't reading on preventDefault()... issue pass it an event!?!
//test that it grabs the info... issue clears at the end
//test that it sends the info
//test that it clears the info
// describe('sendForm', function () {
//   it('should clear the values of the input fields', function(){
//     $('#name').val('bob');
//     $('#phone').val('555-555-5555');
//     $('#email').val('bob@aol.com');
//     $('#twitter').val('@bob');
//     $('#photo').val('http:imgur.com/bob');
//     sendForm({originalEvent: MouseEvent, type: "click"});
//     expect('#name').val().to.equal(' ');
//   });
// });

describe('stringifyInputValues', function () {
  it('should produce a json string', function () {
    //do stuff here
  });
});//end stringifyInputValues

// describe('showForm', function () {
//   it('should give a style attribute of "display: block" to the form', function () {
//     //same issue as above accessing the style attribute of undefined!! b/c it is a jquery object??
//   })
// })

// describe('hideForm', function () {
//   it('should give a style attribute of "display: none" to the form', function () {
//     //style='display:none'
//     hideForm();
//     var displayAttr = document.querySelector('#contactForm').style;
//     expect(displayAttr).to.equal('none');
//   });
// });
<|endoftext|>


<commit_before>import Request from 'superagent';
import Q from 'q';
import AWS from 'aws-sdk';
import { dispatch } from 'redux';
import _ from 'lodash';

import StoreSingleton from '../redux/storeSingleton.js';

import { kGlobalConstants } from '../GlobalConstants.js';
import * as uploadActions from '../redux/actions/uploadActions.js';

import { fileTypes } from '../containers/addData/fileTypes.js';

const fetchStatus = (submissionId) => {
	const deferred = Q.defer();

	Request.post(kGlobalConstants.API + 'check_status/')
	        .withCredentials()
	        .send({'submission_id': submissionId})
	        .end((errFile, res) => {

	        	if (errFile) {
	        		deferred.reject(errFile);
	        	}
	        	else {
	        		deferred.resolve(res.body);
	        	}

	        });

	return deferred.promise;
}

export const fetchErrorReports = (submissionId) => {
	const deferred = Q.defer();

	Request.post(kGlobalConstants.API + 'submission_error_reports/')
			.withCredentials()
			.send({'submission_id': submissionId})
			.end((errFile, res) => {

				if (errFile) {
					deferred.reject(errFile);
				}
				else {
					deferred.resolve(res.body);
				}

			});

	return deferred.promise;
}

const getFileStates = (status) => {
	let output = {};

	status.jobs.forEach((item) => {
		output[item.file_type] = item;
		output[item.file_type].report = null;
	});

	return output;
}

const getFileReports = (status, reports) => {

	for (let key in status) {
		let item = status[key];
		item.report = reports['job_' + item.job_id + '_error_url'];

		// alphabetize any missing and duplicated headers
		item.missing_headers = _.sortBy(item.missing_headers);
		item.duplicated_headers = _.sortBy(item.duplicated_headers);

	}

	return status;
}

export const validateSubmission  = (submissionId) => {

	const deferred = Q.defer();

	// set the submission ID
	const store = new StoreSingleton().store;
	store.dispatch(uploadActions.setSubmissionId(submissionId));

	let status;

	fetchStatus(submissionId)
		.then((statusRes) => {
			status = getFileStates(statusRes);
			return fetchErrorReports(submissionId);
		})
		.then((reports) => {
			getFileReports(status, reports);
			deferred.resolve(status);
		})
		.catch((err) => {
			deferred.reject(err);
		});

	return deferred.promise;

}
<commit_msg>Review helper bug fix<commit_after>import Request from 'superagent';
import Q from 'q';
import AWS from 'aws-sdk';
import { dispatch } from 'redux';
import _ from 'lodash';

import StoreSingleton from '../redux/storeSingleton.js';

import { kGlobalConstants } from '../GlobalConstants.js';
import * as uploadActions from '../redux/actions/uploadActions.js';

import { fileTypes } from '../containers/addData/fileTypes.js';

const fetchStatus = (submissionId) => {
	const deferred = Q.defer();

	Request.post(kGlobalConstants.API + 'check_status/')
	        .withCredentials()
	        .send({'submission_id': submissionId})
	        .end((errFile, res) => {

	        	if (errFile) {
	        		deferred.reject(errFile);
	        	}
	        	else {
	        		deferred.resolve(res.body);
	        	}

	        });

	return deferred.promise;
}

export const fetchErrorReports = (submissionId) => {
	const deferred = Q.defer();

	Request.post(kGlobalConstants.API + 'submission_error_reports/')
			.withCredentials()
			.send({'submission_id': submissionId})
			.end((errFile, res) => {

				if (errFile) {
					deferred.reject(errFile);
				}
				else {
					deferred.resolve(res.body);
				}

			});

	return deferred.promise;
}

const getFileStates = (status) => {
	let output = {};

	status.jobs.forEach((item) => {
		output[item.file_type] = item;
		output[item.file_type].report = null;

		// force an error_data array if no field is passed back in the JSON
		if (!item.hasOwnProperty('error_data')) {
			output[item.file_type].error_data = [];
		}

	});

	return output;
}

const getFileReports = (status, reports) => {

	for (let key in status) {
		let item = status[key];
		item.report = reports['job_' + item.job_id + '_error_url'];

		// alphabetize any missing and duplicated headers
		item.missing_headers = _.sortBy(item.missing_headers);
		item.duplicated_headers = _.sortBy(item.duplicated_headers);
	}

	return status;
}

export const validateSubmission  = (submissionId) => {

	const deferred = Q.defer();

	// set the submission ID
	const store = new StoreSingleton().store;
	store.dispatch(uploadActions.setSubmissionId(submissionId));

	let status;

	fetchStatus(submissionId)
		.then((statusRes) => {
			status = getFileStates(statusRes);
			return fetchErrorReports(submissionId);
		})
		.then((reports) => {
			getFileReports(status, reports);
			deferred.resolve(status);
		})
		.catch((err) => {
			deferred.reject(err);
		});

	return deferred.promise;

}
<|endoftext|>


<commit_before>/*jshint node:true */
"use strict";

module.exports = function(grunt) {

    var nwdir = global.nwdir = grunt.option("nwdir") || "node-webkit-v0.5.1-win-ia32";

    grunt.loadNpmTasks("grunt-contrib-compress");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-mkdir");
    grunt.loadNpmTasks("grunt-shell");
    grunt.loadNpmTasks("grunt-bumpup");

    grunt.loadTasks("./build/");

    grunt.initConfig({
        pkg : grunt.file.readJSON("./package.json"),

        bumpup : "package.json",

        compress : {
            tristis : {
                src : [
                    "package.json",
                    "config/**",
                    "src/**",
                    "node_modules/**",
                    // Filter dev node_modules
                    "!node_modules/grunt*/**",
                    "!node_modules/yui-configger/**",
                    // Filter un-used yui code
                    "!node_modules/yui/**/*.swf",
                    "!node_modules/yui/**/*-coverage.js",
                    "!node_modules/yui/**/*-debug.js",
                    "!node_modules/yui/**/*-min.js"
                ],

                options : {
                    mode    : "zip",
                    level   : 0,
                    archive : "./bin/tristis.nw"
                }
            },

            release : {
                files : [
                    {
                        expand: true,
                        src : "./tristis.exe",
                        cwd : "./bin"
                    }, {
                        expand  : true,
                        flatten : true,
                        src     : [ "**/*.dll", "**/*.pak" ],
                        cwd     : "./bin/" + nwdir
                    }
                ],

                options : {
                    mode    : "zip",
                    level   : 7,
                    archive : "./bin/tristis-v<%= pkg.version %>.zip"
                }
            }
        },

        mkdir : {
            bin : {
                options : {
                    create : [ "bin" ]
                }
            }
        },

        shell : {
            launch : {
                command : "nw.exe ../../",
                options : {
                    execOptions : {
                        cwd : "./bin/" + nwdir + "/"
                    }
                }
            },

            debug : {
                command : "nw.exe ../../ --debug",
                options : {
                    execOptions : {
                        cwd : "./bin/" + nwdir + "/"
                    }
                }
            }
        },

        watch : {
            templates : {
                files : [ "src/templates/**", "!src/templates/compiled/**" ],
                tasks : "template"
            },

            // Disabled until I figure out some configger issues
            /*modules : {
                files : [ "src/js/**", "!src/js/_config*", "!src/js/debug.js" ],
                tasks : "yui"
            }*/
        }
    });

    // Task for updating the pkg config property. Needs to be run after
    // bumpup so the next tasks in queue can work with updated values.
    grunt.registerTask("updatePkg", function () {
        grunt.config.set("pkg", grunt.file.readJSON("package.json"));
    });

    grunt.registerTask("default",     [ "shell:launch" ]);
    grunt.registerTask("debug",       [ "shell:debug" ]);

    grunt.registerTask("release", "", function(type) {
        type || (type = "patch");

        grunt.task.run(
            "bumpup:" + type,
            // yui,
            "template",
            "mkdir",
            "tag",
            "updatePkg",
            "compress:tristis",
            "package",
            "compress:release"
        );
    });

    grunt.registerTask("deploy", [ "ftp" ]);
};
<commit_msg>Move package.json re-read earlier<commit_after>/*jshint node:true */
"use strict";

module.exports = function(grunt) {

    var nwdir = global.nwdir = grunt.option("nwdir") || "node-webkit-v0.5.1-win-ia32";

    grunt.loadNpmTasks("grunt-contrib-compress");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks("grunt-mkdir");
    grunt.loadNpmTasks("grunt-shell");
    grunt.loadNpmTasks("grunt-bumpup");

    grunt.loadTasks("./build/");

    grunt.initConfig({
        pkg : grunt.file.readJSON("./package.json"),

        bumpup : "package.json",

        compress : {
            tristis : {
                src : [
                    "package.json",
                    "config/**",
                    "src/**",
                    "node_modules/**",
                    // Filter dev node_modules
                    "!node_modules/grunt*/**",
                    "!node_modules/yui-configger/**",
                    // Filter un-used yui code
                    "!node_modules/yui/**/*.swf",
                    "!node_modules/yui/**/*-coverage.js",
                    "!node_modules/yui/**/*-debug.js",
                    "!node_modules/yui/**/*-min.js"
                ],

                options : {
                    mode    : "zip",
                    level   : 0,
                    archive : "./bin/tristis.nw"
                }
            },

            release : {
                files : [
                    {
                        expand: true,
                        src : "./tristis.exe",
                        cwd : "./bin"
                    }, {
                        expand  : true,
                        flatten : true,
                        src     : [ "**/*.dll", "**/*.pak" ],
                        cwd     : "./bin/" + nwdir
                    }
                ],

                options : {
                    mode    : "zip",
                    level   : 7,
                    archive : "./bin/tristis-v<%= pkg.version %>.zip"
                }
            }
        },

        mkdir : {
            bin : {
                options : {
                    create : [ "bin" ]
                }
            }
        },

        shell : {
            launch : {
                command : "nw.exe ../../",
                options : {
                    execOptions : {
                        cwd : "./bin/" + nwdir + "/"
                    }
                }
            },

            debug : {
                command : "nw.exe ../../ --debug",
                options : {
                    execOptions : {
                        cwd : "./bin/" + nwdir + "/"
                    }
                }
            }
        },

        watch : {
            templates : {
                files : [ "src/templates/**", "!src/templates/compiled/**" ],
                tasks : "template"
            },

            // Disabled until I figure out some configger issues
            /*modules : {
                files : [ "src/js/**", "!src/js/_config*", "!src/js/debug.js" ],
                tasks : "yui"
            }*/
        }
    });

    // Task for updating the pkg config property. Needs to be run after
    // bumpup so the next tasks in queue can work with updated values.
    grunt.registerTask("updatePkg", function () {
        grunt.config.set("pkg", grunt.file.readJSON("package.json"));
    });

    grunt.registerTask("default",     [ "shell:launch" ]);
    grunt.registerTask("debug",       [ "shell:debug" ]);

    grunt.registerTask("release", "", function(type) {
        type || (type = "patch");

        grunt.task.run(
            "bumpup:" + type,
            "updatePkg",
            // yui,
            "template",
            "mkdir",
            "tag",
            "compress:tristis",
            "package",
            "compress:release"
        );
    });

    grunt.registerTask("deploy", [ "ftp" ]);
};
<|endoftext|>


<commit_before>/* jshint node:true */
module.exports = function (grunt) {
    'use strict';
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        assemble: {
//            options: {
//                postprocess: require('pretty')
//            },
            demo: {
                options: {
                    partials: ['templates/includes/*.hbs'],
                    layoutdir: 'templates',
                    layout: 'index.html'
                },
                src: ['*.md'],
                dest: './'
            }
        },

        sass: {
            options: {
                includePaths: ['bower_components/foundation/scss']
            },
            dist: {
                options: {
                    outputStyle: 'compressed'
                },
                files: {
                    'css/app.css': 'scss/app.scss'
                }
            }
        },

        watch: {
            grunt: { files: ['Gruntfile.js'] },

            sass: {
                options: { livereload: true },
                files: 'scss/**/*.scss',
                tasks: ['sass']
            },

            html_source: {
                files: ['*.md', 'templates/**'],
                tasks: ['assemble']
            },

            html: {
                options: { livereload: true },
                files: ['*.html']
            },

            js: {
                options: { livereload: true },
                files: 'js-source/**/*.js',
                tasks: ['uglify']
            }
        },

        open: {
            server: {
                path: 'http://localhost:9000'
            }
        },

        connect: {
            server: {
                options: {
                    port: 9000,
                    hostname: '*',
                    base: './',
                    middleware: function (connect, options) {
                        var path = require('path');
                        return [
                            require('connect-livereload')(),
                            connect.static(path.resolve('.'))
                        ];
                    }
                }
            }
        },

        uglify: {
            js: {
                options: {
                    sourceMap: 'app.js.map',
                    sourceMapRoot: '../js/'
                },
                files: {
                    'js/app.js': ['js-source/app.js']
                }
            }
        },

        favicons: {
            options: {},
            icons: {
                src: 'assets/HTML5.png',
                dest: './'
            }
        }
    });

    grunt.loadNpmTasks('assemble');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-open');
    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-favicons');

    grunt.registerTask('build', ['assemble', 'sass', 'uglify']);
    grunt.registerTask('default', ['build', 'connect', 'open', 'watch']);
}<commit_msg>Fix path for JS source maps<commit_after>/* jshint node:true */
module.exports = function (grunt) {
    'use strict';
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        assemble: {
//            options: {
//                postprocess: require('pretty')
//            },
            demo: {
                options: {
                    partials: ['templates/includes/*.hbs'],
                    layoutdir: 'templates',
                    layout: 'index.html'
                },
                src: ['*.md'],
                dest: './'
            }
        },

        sass: {
            options: {
                includePaths: ['bower_components/foundation/scss']
            },
            dist: {
                options: {
                    outputStyle: 'compressed'
                },
                files: {
                    'css/app.css': 'scss/app.scss'
                }
            }
        },

        watch: {
            grunt: { files: ['Gruntfile.js'] },

            sass: {
                options: { livereload: true },
                files: 'scss/**/*.scss',
                tasks: ['sass']
            },

            html_source: {
                files: ['*.md', 'templates/**'],
                tasks: ['assemble']
            },

            html: {
                options: { livereload: true },
                files: ['*.html']
            },

            js: {
                options: { livereload: true },
                files: 'js-source/**/*.js',
                tasks: ['uglify']
            }
        },

        open: {
            server: {
                path: 'http://localhost:9000'
            }
        },

        connect: {
            server: {
                options: {
                    port: 9000,
                    hostname: '*',
                    base: './',
                    middleware: function (connect, options) {
                        var path = require('path');
                        return [
                            require('connect-livereload')(),
                            connect.static(path.resolve('.'))
                        ];
                    }
                }
            }
        },

        uglify: {
            js: {
                options: {
                    sourceMap: 'app.js.map',
                    sourceMapRoot: './js/'
                },
                files: {
                    'js/app.js': ['js-source/app.js']
                }
            }
        },

        favicons: {
            options: {},
            icons: {
                src: 'assets/HTML5.png',
                dest: './'
            }
        }
    });

    grunt.loadNpmTasks('assemble');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-open');
    grunt.loadNpmTasks('grunt-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-favicons');

    grunt.registerTask('build', ['assemble', 'sass', 'uglify']);
    grunt.registerTask('default', ['build', 'connect', 'open', 'watch']);
}<|endoftext|>


<commit_before>describe('ns.router', function() {

    describe('API', function() {

        it('should be defined', function() {
            expect(ns.router).to.be.a('function');
        });

        it('ns.router.init should be defined', function() {
            expect(ns.router.init).to.be.a('function');
        });

        it('ns.router.regexps should be defined', function() {
            expect(ns.router.regexps).to.be.an('object');
        });
    });

    describe('routes', function() {

        beforeEach(function() {
            ns.router.routes = {
                redirect: {
                    '/': '/inbox'
                },
                route: {
                    '/inbox': 'messages',
                    '/message/{mid:int}': 'message'
                }
            };
            ns.router.init();
        });

        var test_route = function(url, params, test_name) {
            test_name = test_name || (url + ' -> ' + params.page);
            it(test_name, function() {
                expect(ns.router(url)).to.be.eql(params);
            });
        };

        test_route('/', {page: ns.R.REDIRECT, params: {}, redirect: '/inbox'});
        test_route('/inbox', {page: 'messages', params: {}});
        test_route('/inbox/', {page: 'messages', params: {}});

        test_route('/message', {page: ns.R.NOT_FOUND, params: {}});
        test_route('/message/', {page: ns.R.NOT_FOUND, params: {}});

        test_route('/message/12345', {page: 'message', params: {mid: '12345'}});
        test_route('/message/12345/', {page: 'message', params: {mid: '12345'}});
    });

    describe('default value', function() {

        beforeEach(function() {
            ns.router.regexps[ 'page' ] = 'folder|home';
            ns.router.routes = {
                route: {
                    '/messages/{folder=inbox:id}/{message_id:int}': 'message',
                    '/folder/{folder=inbox:id}': 'folder',
                    '/{page=home:page}': 'page'
                }
            };
            ns.router.init();
        });

        var test_route = function(url, page, params, test_name) {
            it(test_name || url, function() {
                expect(ns.router(url)).to.be.eql({ page: page, params: params });
            });
        };

        test_route('/folder/',        'folder', { folder: 'inbox' });
        test_route('/folder/inbox',   'folder', { folder: 'inbox' });
        test_route('/folder/starred', 'folder', { folder: 'starred' });
        test_route('/folder',         'folder', { folder: 'inbox' }, '/folder : slash near param with default value can collapse');

        test_route('/', 'page', { page: 'home' }, '/ resolved to default value of a custom type');

        test_route('/messages/inbox/45?var1=val1&var2=val2', 'message', { folder: 'inbox', message_id: '45', var1: 'val1', var2: 'val2' });
        //FIXME
        //test_route('/messages/inbox/45?var1=val1&',           'message', { folder: 'inbox', message_id: '45', var1: 'val1' });
        test_route('/messages/inbox/45?var1=val1',           'message', { folder: 'inbox', message_id: '45', var1: 'val1' });
        //  NOTE может надо какое-то другое значение для val1 ?
        test_route('/messages/inbox/45?val1',                'message', { folder: 'inbox', message_id: '45', val1: '' });
        test_route('/messages/inbox/45?',                    'message', { folder: 'inbox', message_id: '45' });
        test_route('/messages/inbox/45',                     'message', { folder: 'inbox', message_id: '45' });

        test_route('/messages/45?var1=val1&var2=val2', 'message', { folder: 'inbox', message_id: '45', var1: 'val1', var2: 'val2' });
        test_route('/messages/45?var1=val1',           'message', { folder: 'inbox', message_id: '45', var1: 'val1' });
        test_route('/messages/45?val1',                'message', { folder: 'inbox', message_id: '45', val1: '' });
        test_route('/messages/45?',                    'message', { folder: 'inbox', message_id: '45' });
        test_route('/messages/45',                     'message', { folder: 'inbox', message_id: '45' });

        // fail
        test_route('/messages//45?var1=val1&var2=val2', 'not-found', {}, '/messages//45?var1=val1&var2=val2: MUST FAIL');
        test_route('/messages//45?var1=val1',           'not-found', {}, '/messages//45?var1=val1: MUST FAIL');
        test_route('/messages//45?val1',                'not-found', {}, '/messages//45?val1: MUST FAIL');
        test_route('/messages//45?',                    'not-found', {}, '/messages//45?: MUST FAIL');
        test_route('/messages//45',                     'not-found', {}, '/messages//45: MUST FAIL');
    });

    describe('baseDir: routing', function() {
        beforeEach(function() {
            ns.router.baseDir = '/ver2';
            ns.router.routes = {
                route: {
                    '/index': 'index'
                }
            };
            ns.router.init();
            this.not_found = { page: ns.R.NOT_FOUND, params: {} };
        });

        afterEach(function() {
            delete ns.router._routes;
            delete ns.router.routes;
            ns.router.baseDir= '';
        });

        it('NOT FOUND in case url does not match baseDir', function() {
            var that = this;
            expect(ns.router('/index')).to.eql(that.not_found);
            expect(ns.router('/ver1/index')).to.eql(that.not_found);
        });

        it('prefixed url is routed fine', function() {
            expect(ns.router('/ver2/index')).to.be.eql({ page: 'index', params: {} });
        });
    });

    describe('baseDir: url generate with baseDir', function() {
        beforeEach(function() {
            ns.router.baseDir = '/ver2';
            ns.router.routes = {};
            ns.router.init();
        });

        afterEach(function() {
            delete ns.router._routes;
            delete ns.router.routes;
            ns.router.baseDir= '';
        });

        // URL GENERATION
        it('generate prefixed url when baseDir is not empty', function() {
            expect(ns.router.url('/index')).to.be.eql('/ver2/index');
        });
    });

    describe('baseDir: url generate without baseDir', function() {
        beforeEach(function() {
            ns.router.routes = {};
            ns.router.init();
        });

        afterEach(function() {
            delete ns.router._routes;
            delete ns.router.routes;
            ns.router.baseDir= '';
        });

        it('generate unprefixed url when baseDir is empty', function() {
            expect(ns.router.url('/index')).to.be.eql('/index');
        });
    });
});
<commit_msg>fix tests<commit_after>describe('ns.router', function() {

    describe('API', function() {

        it('should be defined', function() {
            expect(ns.router).to.be.a('function');
        });

        it('ns.router.init should be defined', function() {
            expect(ns.router.init).to.be.a('function');
        });

        it('ns.router.regexps should be defined', function() {
            expect(ns.router.regexps).to.be.an('object');
        });
    });

    describe('routes', function() {

        beforeEach(function() {
            ns.router.routes = {
                redirect: {
                    '/': '/inbox'
                },
                route: {
                    '/inbox': 'messages',
                    '/message/{mid:int}': 'message'
                }
            };
            ns.router.init();
        });

        var test_route = function(url, params, test_name) {
            test_name = test_name || (url + ' -> ' + params.page);
            it(test_name, function() {
                expect(ns.router(url)).to.be.eql(params);
            });
        };

        test_route('/', {page: ns.R.REDIRECT, params: {}, redirect: '/inbox'});
        test_route('/inbox', {page: 'messages', params: {}});
        test_route('/inbox/', {page: 'messages', params: {}});

        test_route('/message', {page: ns.R.NOT_FOUND, params: {}});
        test_route('/message/', {page: ns.R.NOT_FOUND, params: {}});

        test_route('/message/12345', {page: 'message', params: {mid: '12345'}});
        test_route('/message/12345/', {page: 'message', params: {mid: '12345'}});
    });

    describe('default value', function() {

        beforeEach(function() {
            ns.router.regexps[ 'page' ] = 'folder|home';
            ns.router.routes = {
                route: {
                    '/messages/{folder=inbox:id}/{message_id:int}': 'message',
                    '/folder/{folder=inbox:id}': 'folder',
                    '/{page=home:page}': 'page'
                }
            };
            ns.router.init();
        });

        var test_route = function(url, page, params, test_name) {
            it(test_name || url, function() {
                expect(ns.router(url)).to.be.eql({ page: page, params: params });
            });
        };

        test_route('/folder/',        'folder', { folder: 'inbox' });
        test_route('/folder/inbox',   'folder', { folder: 'inbox' });
        test_route('/folder/starred', 'folder', { folder: 'starred' });
        test_route('/folder',         'folder', { folder: 'inbox' }, '/folder : slash near param with default value can collapse');

        test_route('/', 'page', { page: 'home' }, '/ resolved to default value of a custom type');

        test_route('/messages/inbox/45?var1=val1&var2=val2', 'message', { folder: 'inbox', message_id: '45', var1: 'val1', var2: 'val2' });
        //FIXME
        //test_route('/messages/inbox/45?var1=val1&',           'message', { folder: 'inbox', message_id: '45', var1: 'val1' });
        test_route('/messages/inbox/45?var1=val1',           'message', { folder: 'inbox', message_id: '45', var1: 'val1' });
        //  NOTE может надо какое-то другое значение для val1 ?
        test_route('/messages/inbox/45?val1',                'message', { folder: 'inbox', message_id: '45', val1: '' });
        test_route('/messages/inbox/45?',                    'message', { folder: 'inbox', message_id: '45' });
        test_route('/messages/inbox/45',                     'message', { folder: 'inbox', message_id: '45' });

        test_route('/messages/45?var1=val1&var2=val2', 'message', { folder: 'inbox', message_id: '45', var1: 'val1', var2: 'val2' });
        test_route('/messages/45?var1=val1',           'message', { folder: 'inbox', message_id: '45', var1: 'val1' });
        test_route('/messages/45?val1',                'message', { folder: 'inbox', message_id: '45', val1: '' });
        test_route('/messages/45?',                    'message', { folder: 'inbox', message_id: '45' });
        test_route('/messages/45',                     'message', { folder: 'inbox', message_id: '45' });

        // fail
        test_route('/messages//45?var1=val1&var2=val2', 'not-found', {}, '/messages//45?var1=val1&var2=val2: MUST FAIL');
        test_route('/messages//45?var1=val1',           'not-found', {}, '/messages//45?var1=val1: MUST FAIL');
        test_route('/messages//45?val1',                'not-found', {}, '/messages//45?val1: MUST FAIL');
        test_route('/messages//45?',                    'not-found', {}, '/messages//45?: MUST FAIL');
        test_route('/messages//45',                     'not-found', {}, '/messages//45: MUST FAIL');
    });

    describe('baseDir: routing', function() {
        beforeEach(function() {
            ns.router.baseDir = '/ver2';
            ns.router.routes = {
                route: {
                    '/index': 'index'
                }
            };
            ns.router.init();
            this.not_app_url = ;
        });

        afterEach(function() {
            delete ns.router._routes;
            delete ns.router.routes;
            ns.router.baseDir= '';
        });

        it('NOT_APP_URL in case url does not match baseDir', function() {
            var that = this;
            expect(ns.router('/ver1/index')).to.eql({
                page: ns.R.NOT_APP_URL,
                params: {},
                redirect: '/ver1/index'
            });
        });

        it('NOT_APP_URL in case url does not match baseDir but match route', function() {
            expect(ns.router('/index')).to.eql({
                page: ns.R.NOT_APP_URL,
                params: {},
                redirect: '/index'
            });
        });

        it('prefixed url is routed fine', function() {
            expect(ns.router('/ver2/index')).to.be.eql({ page: 'index', params: {} });
        });
    });

    describe('baseDir: url generate with baseDir', function() {
        beforeEach(function() {
            ns.router.baseDir = '/ver2';
            ns.router.routes = {};
            ns.router.init();
        });

        afterEach(function() {
            delete ns.router._routes;
            delete ns.router.routes;
            ns.router.baseDir= '';
        });

        // URL GENERATION
        it('generate prefixed url when baseDir is not empty', function() {
            expect(ns.router.url('/index')).to.be.eql('/ver2/index');
        });
    });

    describe('baseDir: url generate without baseDir', function() {
        beforeEach(function() {
            ns.router.routes = {};
            ns.router.init();
        });

        afterEach(function() {
            delete ns.router._routes;
            delete ns.router.routes;
            ns.router.baseDir= '';
        });

        it('generate unprefixed url when baseDir is empty', function() {
            expect(ns.router.url('/index')).to.be.eql('/index');
        });
    });
});
<|endoftext|>


<commit_before>/*!
 * .______    _______     ___      .______       ______     ___   .__________.
 * (   _  )  (   ____)   /   \     (   _  )     (      )   /   \  (          )
 * |  |_)  ) |  |__     /  ^  \    |  |_)  )   |  ,----'  /  ^  \ `---|  |---`
 * |   _  <  |   __)   /  /_\  \   |      )    |  |      /  /_\  \    |  |
 * |  |_)  ) |  |____ /  _____  \  |  |)  ----.|  `----./  _____  \   |  |
 * (______)  (_______/__/     \__\ ( _| `.____) (______)__/     \__\  |__|
 *
 * Bearcat ConfigLoader
 * Copyright(c) 2015 fantasyni <fantasyni@163.com>
 * MIT Licensed
 */

var logger = require('pomelo-logger').getLogger('bearcat', 'ConfigLoader');
var RequireUtil = require('../util/requireUtil');
var MetaUtil = require('../util/metaUtil');
var Constant = require('../util/constant');
var MetaLoader = require('./metaLoader');
var Utils = require('../util/utils');
var Path = RequireUtil.requirePath();

/**
 * ConfigLoader constructor function.
 *
 * @api public
 */
var ConfigLoader = function() {
	// this.loadedContextBeans = {};
}

module.exports = ConfigLoader;

/**
 * ConfigLoader get meta loader.
 *
 * @return  {Object} meta loader
 * @api public
 */
ConfigLoader.prototype.getMetaLoader = function() {
	return new MetaLoader();
}

/**
 * ConfigLoader get meta objects from context path.
 *
 * @param   {String} cpath context path
 * @return  {Object} meta objects
 * @api public
 */
ConfigLoader.prototype.getResources = function(cpath) {
	var scanPaths = [];
	var metaObjects = {};
	var metaLoader = this.getMetaLoader();
	this.getRecursiveScanPath(cpath, scanPaths, metaObjects);

	for (var beanName in metaObjects) {
		metaLoader.setMetaObject(beanName, metaObjects[beanName]);
	}

	for (var i = 0; i < scanPaths.length; i++) {
		metaLoader.load(scanPaths[i]);
	}

	return metaLoader.getMetaObejcts();
}

/**
 * ConfigLoader get recursive scan paths and metaObjects in context.json.
 *
 * @param   {String} cpath context path
 * @param   {Array}  scanPaths scan paths
 * @param   {Object} metaObjects
 * @api public
 */
ConfigLoader.prototype.getRecursiveScanPath = function(cpath, scanPaths, metaObjects) {
	var context = Utils.myRequire(cpath);
	if (!context) {
		return;
	}

	var scan = context.scan;
	var beans = context.beans;
	var browser = context.browser;
	var imports = context.imports;
	var namespace = context.namespace;
	var dependencies = context.dependencies;

	var dpath = Path.dirname(cpath);

	if (Utils.checkString(browser)) {
		this.getRecursiveScanPath(dpath + '/' + browser, scanPaths, metaObjects);
		return;
	} else if (Utils.checkArray(browser)) {
		for (var i = 0; i < browser.length; i++) {
			this.getRecursiveScanPath(dpath + '/' + browser[i], scanPaths, metaObjects);
		}
		return;
	}

	for (var dependency in dependencies) {
		this.getRecursiveScanPath(dpath + '/node_modules/' + dependency + '/context.json', scanPaths, metaObjects);
	}

	if (Utils.checkArray(imports)) {
		for (var j = 0; j < imports.length; j++) {
			this.getRecursiveScanPath(dpath + '/' + imports[j], scanPaths, metaObjects);
		}
	}

	// context.json defined bean metadatas
	if (beans) {
		for (var i = 0; i < beans.length; i++) {
			var bean = beans[i];
			var beanName = bean['id'];

			if (namespace) {
				beanName = namespace + Constant.NAMESPACE_SEPERATOR + beanName;
			}

			// var loadpath = this.loadedContextBeans[beanName];
			// if (beanName && loadpath) {
			// 	logger.warn("bean %j defined in %j has already defined in %j, please check your configuration metadata files", beanName, cpath, loadpath);
			// 	continue;
			// }

			var beanObject = null;
			var funcPath = "";
			if (Utils.checkString(bean['func'])) {
				// beans from require, may be cached by require when you do with the same context.json
				funcPath = Utils.getLoadPath(bean['func'], cpath);
				beanObject = Utils.myRequire(funcPath);
			}

			if (beanObject) {
				if (Utils.checkFunction(beanObject)) {
					bean['func'] = beanObject;
				} else if (Utils.checkObject(beanObject)) {
					if (beanObject['id'] && beanObject['id'] === beanName) {
						// meta defined in js file override context.json
						bean = MetaUtil.mergeMeta(beanObject, bean);
						bean['ftype'] = 'object';
					} else {
						logger.error('meta defined in file %j %j mismatch with that defined in context %j', funcPath, beanObject, bean);
						continue;
					}
				}
			}

			if (beanName) {
				var originMeta = metaObjects[beanName];
				metaObjects[beanName] = MetaUtil.mergeMeta(bean, originMeta);
				if (funcPath) {
					bean['fpath'] = Path.resolve(process.cwd(), funcPath);
				}
				// this.loadedContextBeans[beanName] = cpath;
			}
		}
	}

	if (Utils.checkString(scan)) {
		var scanPath = Utils.getLoadPath2(scan, cpath);
		scanPaths.push(scanPath);
	}

	if (Utils.checkArray(scan)) {
		for (var i = 0; i < scan.length; i++) {
			var scanPath = Utils.getLoadPath2(scan[i], cpath);
			scanPaths.push(scanPath);
		}
	}
}<commit_msg>review configLoader<commit_after>/*!
 * .______    _______     ___      .______       ______     ___   .__________.
 * (   _  )  (   ____)   /   \     (   _  )     (      )   /   \  (          )
 * |  |_)  ) |  |__     /  ^  \    |  |_)  )   |  ,----'  /  ^  \ `---|  |---`
 * |   _  <  |   __)   /  /_\  \   |      )    |  |      /  /_\  \    |  |
 * |  |_)  ) |  |____ /  _____  \  |  |)  ----.|  `----./  _____  \   |  |
 * (______)  (_______/__/     \__\ ( _| `.____) (______)__/     \__\  |__|
 *
 * Bearcat ConfigLoader
 * Copyright(c) 2015 fantasyni <fantasyni@163.com>
 * MIT Licensed
 */

var logger = require('pomelo-logger').getLogger('bearcat', 'ConfigLoader');
var RequireUtil = require('../util/requireUtil');
var MetaUtil = require('../util/metaUtil');
var Constant = require('../util/constant');
var MetaLoader = require('./metaLoader');
var Utils = require('../util/utils');
var Path = RequireUtil.requirePath();

/**
 * ConfigLoader constructor function.
 *
 * @api public
 */
var ConfigLoader = function() {}

module.exports = ConfigLoader;

/**
 * ConfigLoader get meta loader.
 *
 * @return  {Object} meta loader
 * @api public
 */
ConfigLoader.prototype.getMetaLoader = function() {
	return new MetaLoader();
}

/**
 * ConfigLoader get meta objects from context path.
 *
 * @param   {String} cpath context path
 * @return  {Object} meta objects
 * @api public
 */
ConfigLoader.prototype.getResources = function(cpath) {
	var scanPaths = [];
	var metaObjects = {};
	var metaLoader = this.getMetaLoader();
	this.getRecursiveScanPath(cpath, scanPaths, metaObjects);

	for (var beanName in metaObjects) {
		metaLoader.setMetaObject(beanName, metaObjects[beanName]);
	}

	for (var i = 0; i < scanPaths.length; i++) {
		metaLoader.load(scanPaths[i]);
	}

	return metaLoader.getMetaObejcts();
}

/**
 * ConfigLoader get recursive scan paths and metaObjects in context.json.
 *
 * @param   {String} cpath context path
 * @param   {Array}  scanPaths scan paths
 * @param   {Object} metaObjects
 * @api public
 */
ConfigLoader.prototype.getRecursiveScanPath = function(cpath, scanPaths, metaObjects) {
	var context = Utils.myRequire(cpath);
	if (!context) {
		return;
	}

	var scan = context.scan;
	var beans = context.beans;
	var browser = context.browser;
	var imports = context.imports;
	var namespace = context.namespace;
	var dependencies = context.dependencies;

	var dpath = Path.dirname(cpath);

	if (Utils.checkString(browser)) {
		return this.getRecursiveScanPath(dpath + '/' + browser, scanPaths, metaObjects);
	} else if (Utils.checkArray(browser)) {
		for (var i = 0; i < browser.length; i++) {
			this.getRecursiveScanPath(dpath + '/' + browser[i], scanPaths, metaObjects);
		}
		return;
	}

	for (var dependency in dependencies) {
		this.getRecursiveScanPath(dpath + '/node_modules/' + dependency + '/context.json', scanPaths, metaObjects);
	}

	if (Utils.checkArray(imports)) {
		for (var j = 0; j < imports.length; j++) {
			this.getRecursiveScanPath(dpath + '/' + imports[j], scanPaths, metaObjects);
		}
	}

	// context.json defined bean metadatas
	if (beans) {
		for (var i = 0; i < beans.length; i++) {
			var bean = beans[i];
			var beanName = bean['id'];

			if (namespace) {
				beanName = namespace + Constant.NAMESPACE_SEPERATOR + beanName;
			}

			// var loadpath = this.loadedContextBeans[beanName];
			// if (beanName && loadpath) {
			// 	logger.warn("bean %j defined in %j has already defined in %j, please check your configuration metadata files", beanName, cpath, loadpath);
			// 	continue;
			// }

			var beanObject = null;
			var funcPath = "";
			if (Utils.checkString(bean['func'])) {
				// beans from require, may be cached by require when you do with the same context.json
				funcPath = Utils.getLoadPath(bean['func'], cpath);
				beanObject = Utils.myRequire(funcPath);
			}

			if (beanObject) {
				if (Utils.checkFunction(beanObject)) {
					bean['func'] = beanObject;
				} else if (Utils.checkObject(beanObject)) {
					if (beanObject['id'] && beanObject['id'] === beanName) {
						// meta defined in js file override context.json
						bean = MetaUtil.mergeMeta(beanObject, bean);
						bean['ftype'] = 'object';
					} else {
						logger.error('meta defined in file %j %j mismatch with that defined in context %j', funcPath, beanObject, bean);
						continue;
					}
				}
			}

			if (beanName) {
				var originMeta = metaObjects[beanName];
				metaObjects[beanName] = MetaUtil.mergeMeta(bean, originMeta);
				if (funcPath) {
					bean['fpath'] = Path.resolve(process.cwd(), funcPath);
				}
			}
		}
	}

	if (Utils.checkString(scan)) {
		var scanPath = Utils.getLoadPath2(scan, cpath);
		scanPaths.push(scanPath);
	}

	if (Utils.checkArray(scan)) {
		for (var i = 0; i < scan.length; i++) {
			var scanPath = Utils.getLoadPath2(scan[i], cpath);
			scanPaths.push(scanPath);
		}
	}
}<|endoftext|>


<commit_before>Blend.defineClass('Blend.layout.container.Box', {
    extend: 'Blend.layout.container.Layout',
    requires: [
        'Blend.layout.utils.Box'
    ],
    align: 'start',
    pack: 'start',
    margin: 0,
    layoutContext: null,
    direction: null,
    handler: null,
    performLayout: function (force) {
        var me = this, ctx;
        force = force || false;
        if (force) {
            me.layoutContext = null;
        }
        ctx = me.getItemLayoutContexts();
        me.createLayoutContext();
        me.handler(me.containerEl, me.getElements(), ctx, me.layoutContext);
        // call the parent to layout the children
        me.callParent.apply(me, arguments);
    },
    createLayoutContext: function () {
        var me = this;
        if (!me.layoutContext) {
            me.layoutContext = {
                pack: me.pack,
                align: me.align,
                margin: me.margin,
                direction: me.direction,
                bounds: Blend.Element.getBounds(me.containerEl),
                boundsSetter: function (el, bounds, idx) {
                    var view = me.view.items[idx];
                    var vbounds = Blend.Element.getBounds(view.getElement());
                    Blend.Style.set(el, bounds);
                    if (vbounds.top !== bounds.top ||
                            vbounds.left !== bounds.left ||
                            vbounds.width !== bounds.width ||
                            vbounds.height !== bounds.height) {
                        me.view.items[idx].fireEvent('sizeChanged', bounds.width, bounds.height);
                    }

                }
            };
        }
    },
    getItemLayoutContexts: function () {
        var me = this, ctx = [];
        Blend.foreach(me.view.items, function (view) {
            ctx.push(view.getLayoutContext());
        });
        return ctx;
    }
});<commit_msg>Added code doc<commit_after>Blend.defineClass('Blend.layout.container.Box', {
    extend: 'Blend.layout.container.Layout',
    requires: [
        'Blend.layout.utils.Box'
    ],
    align: 'start',
    pack: 'start',
    margin: 0,
    layoutContext: null,
    direction: null,
    handler: null,
    performLayout: function (force) {
        var me = this, ctx;
        force = force || false;
        if (force) {
            me.layoutContext = null;
        }
        ctx = me.getItemLayoutContexts();
        me.createLayoutContext();
        me.handler(me.containerEl, me.getElements(), ctx, me.layoutContext);
        // call the parent to layout the children
        me.callParent.apply(me, arguments);
    },
    createLayoutContext: function () {
        var me = this;
        if (!me.layoutContext) {
            me.layoutContext = {
                pack: me.pack,
                align: me.align,
                margin: me.margin,
                direction: me.direction,
                bounds: Blend.Element.getBounds(me.containerEl),
                boundsSetter: function (el, bounds, idx) {
                    /**
                     * Only call the sizeChanged event if the bounds of the
                     * view is changed. This will avoid unnecessary layout flows
                     */
                    var view = me.view.items[idx];
                    var vbounds = Blend.Element.getBounds(view.getElement());
                    Blend.Style.set(el, bounds);
                    if (vbounds.top !== bounds.top ||
                            vbounds.left !== bounds.left ||
                            vbounds.width !== bounds.width ||
                            vbounds.height !== bounds.height) {
                        me.view.items[idx].fireEvent('sizeChanged', bounds.width, bounds.height);
                    }

                }
            };
        }
    },
    getItemLayoutContexts: function () {
        var me = this, ctx = [];
        Blend.foreach(me.view.items, function (view) {
            ctx.push(view.getLayoutContext());
        });
        return ctx;
    }
});<|endoftext|>


<commit_before>var projectVersion = require("./package.json").version;
module.exports = function(grunt) {
	grunt.initConfig({
		pkg : grunt.file.readJSON('package.json'),
		jshint: {
			beforeconcat: ['./public/assets/js/*.js', '!./public/assets/js/react-component-*.js', '!./public/assets/js/waveform.js', '!./public/assets/js/github.js']
		},
		clean: {
		 	build: {
				src: ['./studio/*'],
				options: { force: true }
		 	},
		 	bower_components: {
				src: ['./studio/bower_components'],
				options: { force: true }
		 	},

		 	after: {
				src: ['./studio/assets/js/react-component-*.js', './studio/assets/js/app.minified.js', './studio/index.js'],
				options: { force: true }
		 	}
		},
		bump: {
			options: {
				files: ['package.json', 'bower.json'],
				updateConfigs: [],
				commit: false,
				commitMessage: 'Release v%VERSION%',
				commitFiles: ['package.json', 'bower.json'], // '-a' for all files
				createTag: true,
				tagName: 'v%VERSION%',
				tagMessage: 'Version %VERSION%',
				push: false,
				pushTo: '',
				gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
			}
		},
		vulcanize: {
	      default: {
	        options: {
	        	strip:true,
	        	csp:true,
	        },
	        files: {
	          './studio/index.html': './studio/index.html'
	        },
	      },
	    },
		'string-replace': {
			html: {
				options: {
					replacements: [
						{
							pattern: /<!-- SCRIPT START [\s\S]*? SCRIPT END -->/,
							replacement: '<script type="text/javascript" src="assets/js/app.min.js"></script>'
						},
						{
							pattern: /<!-- VERSION START [\s\S]*? VERSION END -->/g,
							replacement: projectVersion
						},
						{
							pattern: /<!-- STYLE START [\s\S]*? STYLE END -->/,
							replacement: '<link rel="stylesheet" type="text/css" href="assets/css/app.min.css">'
						}
					]
				},
				files: [
					{expand: false, flatten: false, src: ['./public/index.html'], dest: './studio/index.html'}
				]
			},
			correction: {
				options: {
					replacements: [
						{
							pattern: '<script charset="utf-8" src="index.js"></script>',
							replacement: ''
						},
						{
							pattern: '<script src="bower_components/polymer/polymer.js">',
							replacement: ''
						}
					]
				},
				files: [
					{expand: false, flatten: false, src: ['./studio/index.html'], dest: './studio/index.html'}
				]
			},
		},
		htmlmin: {
			dist: {
			  	options: {
					collapseBooleanAttributes:      true,
					collapseWhitespace:             true,
					removeComments:                 true, // Only if you don't use comment directives!
					removeEmptyAttributes:          true,
					removeRedundantAttributes:      true,
					removeScriptTypeAttributes:     true,
					removeStyleLinkTypeAttributes:  true
			  	},
		  	 	files: [
			      {expand: true,  src: ['./../boom-build/index.html'], dest: './../boom-build/index.html'},
			      //{expand: true, cwd: './public/templates/', src: ['**/*.html'], dest: './public/templates/'}
			    ]
			}
	  	},
		react: {
			files: {
				expand: true,
				cwd: './public/assets/js/',
				src: ['**/react-component*.js'],
				dest: './studio/assets/js',
				ext: '.js'
			}
		},

		copy: {
			assets: {
				files: [
					{
						expand: true,
						cwd: "./public/assets/images",
						src: ["*.*"],
						dest: "./studio/assets/images",
						flatten: false
					},
				]
			},
			bower_components: {
				files: [
					{
						expand: true,
						cwd: "./public/bower_components",
						src: ["**/*"],
						dest: "./studio/bower_components",
						flatten: false
					}
				]
			}
		},

		uglify: {
			options: {
				beautify: true,
				mangle: false,
				preserveComments: true
			},
			my_target: {
				files: {
					'./studio/assets/js/app.minified.js': [
						"./public/bower_components/octokit/octokit.js",
						"./public/assets/js/waveform.js",
						"./public/assets/js/app.js",
						'./studio/assets/js/react-component-*.js',
						"./public/bower_components/webcomponentsjs/webcomponents.js",
						//'public-dev/assets/js/*-controller.js',
					]
				}
			}
		},
		cssmin: {
			combine: {
				files: {
					'./studio/assets/css/app.min.css': [
						'./public/assets/css/main.css'
					]
				}
			}
		},
		concat: {
			options: {
			  separator: '\n',
			},
			dist: {
				src: [
					"./public/bower_components/react/react-with-addons.min.js",
					//"bower_components/react/JSXTransformer.js",
					"./public/bower_components/jquery/dist/jquery.min.js",
					"./public/bower_components/jquery.cookie/jquery.cookie.js",
					"./public/bower_components/ciseaux/build/ciseaux.min.js",
					'./studio/assets/js/app.minified.js',
					"./public/bower_components/polymer/polymer.min.js",
					'./studio/index.js',
				],
				dest: './studio/assets/js/app.min.js',
			},
		},

	});

	// Production Build Tools
	grunt.loadNpmTasks('grunt-react');
	grunt.loadNpmTasks('grunt-vulcanize');
	grunt.loadNpmTasks('grunt-bump');
	grunt.loadNpmTasks('grunt-npm-install');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-string-replace');
	grunt.loadNpmTasks('grunt-remove');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-file-append');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-htmlmin');

	// Default Production Build task(s).
	grunt.registerTask(
		'default', [
			'jshint',
			'clean:build',
			'bump',
			'string-replace:html',
			'copy:bower_components',
			'vulcanize',
			'react',
			'uglify',
			'concat',
			'copy:assets',
			'cssmin',
			'string-replace:correction',
			'clean:bower_components',
			'clean:after'
			/*
			*/
		]
	);

	grunt.registerTask("build", ['default']);
};<commit_msg>fixed build error<commit_after>var projectVersion = require("./package.json").version;
module.exports = function(grunt) {
	grunt.initConfig({
		pkg : grunt.file.readJSON('package.json'),
		jshint: {
			beforeconcat: ['./public/assets/js/*.js', '!./public/assets/js/react-component-*.js', '!./public/assets/js/waveform.js', '!./public/assets/js/github.js']
		},
		clean: {
		 	build: {
				src: ['./studio/*'],
				options: { force: true }
		 	},
		 	bower_components: {
				src: ['./studio/bower_components'],
				options: { force: true }
		 	},

		 	after: {
				src: ['./studio/assets/js/react-component-*.js', './studio/assets/js/app.minified.js', './studio/index.js'],
				options: { force: true }
		 	}
		},
		bump: {
			options: {
				files: ['package.json', 'bower.json'],
				updateConfigs: [],
				commit: false,
				commitMessage: 'Release v%VERSION%',
				commitFiles: ['package.json', 'bower.json'], // '-a' for all files
				createTag: true,
				tagName: 'v%VERSION%',
				tagMessage: 'Version %VERSION%',
				push: false,
				pushTo: '',
				gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
			}
		},
		vulcanize: {
	      default: {
	        options: {
	        	strip:true,
	        	csp:true,
	        },
	        files: {
	          './studio/index.html': './studio/index.html'
	        },
	      },
	    },
		'string-replace': {
			html: {
				options: {
					replacements: [
						{
							pattern: /<!-- SCRIPT START [\s\S]*? SCRIPT END -->/,
							replacement: '<script type="text/javascript" src="assets/js/app.min.js"></script>'
						},
						{
							pattern: /<!-- VERSION START [\s\S]*? VERSION END -->/g,
							replacement: projectVersion
						},
						{
							pattern: /<!-- STYLE START [\s\S]*? STYLE END -->/,
							replacement: '<link rel="stylesheet" type="text/css" href="assets/css/app.min.css">'
						}
					]
				},
				files: [
					{expand: false, flatten: false, src: ['./public/index.html'], dest: './studio/index.html'}
				]
			},
			correction: {
				options: {
					replacements: [
						{
							pattern: '<script charset="utf-8" src="index.js"></script>',
							replacement: ''
						},
						{
							pattern: '<script src="bower_components/polymer/polymer.js">',
							replacement: ''
						}
					]
				},
				files: [
					{expand: false, flatten: false, src: ['./studio/index.html'], dest: './studio/index.html'}
				]
			},
		},
		htmlmin: {
			dist: {
			  	options: {
					collapseBooleanAttributes:      true,
					collapseWhitespace:             true,
					removeComments:                 true, // Only if you don't use comment directives!
					removeEmptyAttributes:          true,
					removeRedundantAttributes:      true,
					removeScriptTypeAttributes:     true,
					removeStyleLinkTypeAttributes:  true
			  	},
		  	 	files: [
			      {expand: true,  src: ['./../boom-build/index.html'], dest: './../boom-build/index.html'},
			      //{expand: true, cwd: './public/templates/', src: ['**/*.html'], dest: './public/templates/'}
			    ]
			}
	  	},
		react: {
			files: {
				expand: true,
				cwd: './public/assets/js/',
				src: ['**/react-component*.js'],
				dest: './studio/assets/js',
				ext: '.js'
			}
		},

		copy: {
			assets: {
				files: [
					{
						expand: true,
						cwd: "./public/assets/images",
						src: ["*.*"],
						dest: "./studio/assets/images",
						flatten: false
					},
				]
			},
			bower_components: {
				files: [
					{
						expand: true,
						cwd: "./public/bower_components",
						src: ["**/*"],
						dest: "./studio/bower_components",
						flatten: false
					}
				]
			}
		},

		uglify: {
			options: {
				beautify: false,
				mangle: true,
				preserveComments: true
			},
			my_target: {
				files: {
					'./studio/assets/js/app.minified.js': [
						"./public/bower_components/octokit/octokit.js",
						"./public/assets/js/waveform.js",
						"./public/assets/js/app.js",
						'./studio/assets/js/react-component-*.js',
						/*"./public/bower_components/webcomponentsjs/webcomponents.js",*/
						//'public-dev/assets/js/*-controller.js',
					]
				}
			}
		},
		cssmin: {
			combine: {
				files: {
					'./studio/assets/css/app.min.css': [
						'./public/assets/css/main.css'
					]
				}
			}
		},
		concat: {
			options: {
			  separator: '\n',
			},
			dist: {
				src: [
					"./public/bower_components/polymer/polymer.min.js",
					"./public/bower_components/react/react-with-addons.min.js",
					//"bower_components/react/JSXTransformer.js",
					"./public/bower_components/jquery/dist/jquery.min.js",
					"./public/bower_components/jquery.cookie/jquery.cookie.js",
					"./public/bower_components/ciseaux/build/ciseaux.min.js",
					'./studio/assets/js/app.minified.js',
					'./studio/index.js',
				],
				dest: './studio/assets/js/app.min.js',
			},
		},

	});

	// Production Build Tools
	grunt.loadNpmTasks('grunt-react');
	grunt.loadNpmTasks('grunt-vulcanize');
	grunt.loadNpmTasks('grunt-bump');
	grunt.loadNpmTasks('grunt-npm-install');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-string-replace');
	grunt.loadNpmTasks('grunt-remove');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-file-append');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-htmlmin');

	// Default Production Build task(s).
	grunt.registerTask(
		'default', [
			'jshint',
			'clean:build',
			'bump',
			'string-replace:html',
			'copy:bower_components',
			'vulcanize',
			'react',
			'uglify',
			'concat',
			'copy:assets',
			'cssmin',
			'string-replace:correction',
			'clean:bower_components',
			'clean:after'
			/*
			*/
		]
	);

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


<commit_before>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        brixjs: {
            brixjs: {
                files: {
                    "dist/<%= pkg.version %>/": "src/"
                }
            }
        },
        brixless: {
            brixless: {
                files: {
                    'dist/<%= pkg.version %>/': 'src/style/',
                    'src/style/': 'src/style/'
                }
            }
        },
        galleryless: {
            galleryless: {
                files: {
                    'dist/<%= pkg.version %>/gallery/': 'src/gallery/'
                }
            }

        },
        galleryjs: {
            gallery: {
                files: {
                    'dist/<%= pkg.version %>/gallery/': 'src/gallery/'
                }
            }
        },
        chartsjs:{
            chartsjs:{
                files:{
                    'dist/<%= pkg.version %>/gallery/charts/':'src/gallery/charts/'
                }
            }
        },
        watch: {
            watchbrixjs: {
                files: 'src/core/*.js',
                tasks: ['brixjs']
            },
            watchgalleryless: {
                files: 'src/gallery/**/*.less',
                tasks: ['galleryless']
            },
            watchgalleryjs: {
                files: 'src/gallery/**/*.js',
                tasks: ['galleryjs']
            },
            watchbrixless: {
                files: 'src/style/*.less',
                tasks: ['brixless']
            }
        },
        jshint: {
            files: [
                'Gruntfile.js', 'src/core/brix.js', 'src/core/mu.js', 'src/core/dataset.js', 'src/core/chunk.js', 'src/core/brick.js', 'src/core/pagelet.js', 'src/core/demolet.js'],
            options: {
                browser: true,
                curly: true,
                eqeqeq: false,
                immed: true,
                latedef: true,
                newcap: false,
                noarg: true,
                sub: true,
                undef: true,
                boss: true,
                eqnull: true,
                evil: true,
                expr: true,
                laxcomma: true,
                globals: {
                    exports: true,
                    module: false,
                    KISSY: true,
                    console: true,
                    print: true,
                    document: true,
                    window: true
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-watch');

    //tasks
    grunt.loadTasks('tasks');

    // Default task.
    //grunt.registerTask('default', ['chartsjs']);
    grunt.registerTask('default', ['jshint','brixjs' ,'brixless','galleryless', 'galleryjs' ,'chartsjs', 'watch']);
};<commit_msg>update gruntfile<commit_after>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        brixjs: {
            brixjs: {
                files: {
                    "dist/<%= pkg.version %>/": "src/"
                }
            }
        },
        brixless: {
            brixless: {
                files: {
                    'dist/<%= pkg.version %>/': 'src/style/',
                    'src/style/': 'src/style/'
                }
            }
        },
        galleryjs: {
            gallery: {
                files: {
                    'dist/<%= pkg.version %>/gallery/': 'src/gallery/'
                }
            }
        },
        galleryless: {
            galleryless: {
                files: {
                    'dist/<%= pkg.version %>/gallery/': 'src/gallery/'
                }
            }

        },
        chartsjs:{
            chartsjs:{
                files:{
                    'dist/<%= pkg.version %>/gallery/charts/':'src/gallery/charts/'
                }
            }
        },
        watch: {
            watchbrixjs: {
                files: 'src/core/*.js',
                tasks: ['brixjs']
            },
            watchgalleryless: {
                files: 'src/gallery/**/*.less',
                tasks: ['galleryless']
            },
            watchgalleryjs: {
                files: 'src/gallery/**/*.js',
                tasks: ['galleryjs']
            },
            watchbrixless: {
                files: 'src/style/*.less',
                tasks: ['brixless']
            }
        },
        jshint: {
            files: [
                'Gruntfile.js', 'src/core/brix.js', 'src/core/mu.js', 'src/core/dataset.js', 'src/core/chunk.js', 'src/core/brick.js', 'src/core/pagelet.js', 'src/core/demolet.js'],
            options: {
                browser: true,
                curly: true,
                eqeqeq: false,
                immed: true,
                latedef: true,
                newcap: false,
                noarg: true,
                sub: true,
                undef: true,
                boss: true,
                eqnull: true,
                evil: true,
                expr: true,
                laxcomma: true,
                globals: {
                    exports: true,
                    module: false,
                    KISSY: true,
                    console: true,
                    print: true,
                    document: true,
                    window: true
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-watch');

    //tasks
    grunt.loadTasks('tasks');

    // Default task.
    //grunt.registerTask('default', ['chartsjs']);
    grunt.registerTask('default', ['jshint','brixjs' ,'brixless','galleryless', 'galleryjs' ,'chartsjs', 'watch']);
};<|endoftext|>


<commit_before>/*eslint-env node */

module.exports = function (grunt) {
    'use strict';

    grunt.util.linefeed = '\n';

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

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        banner: (
            "/*!\n * mq4-hover-shim v<%= pkg.version %>\n" +
            " * <%= pkg.homepage %>\n" +
            " * Copyright (c) 2014-2015 Christopher Rebert\n" +
            " * Licensed under the MIT License (https://github.com/twbs/mq4-hover-shim/blob/master/LICENSE).\n" +
            " */\n"
        ),

        '6to5': {
            options: {
                loose: ['es6.modules'],
                modules: "common" // output a CommonJS module
            },
            dist: {
                files: {
                    'dist/cjs/<%= pkg.name %>.js': 'src/browser/<%= pkg.name %>.js'
                }
            }
        },
        browserify: {
            options: {
                banner: '<%= banner %>',
                browserifyOptions: {
                    standalone: 'mq4HoverShim',
                    bundleExternal: false
                }
            },
            dist: {
                src: 'dist/cjs/<%= pkg.name %>.js',
                dest: 'dist/browser/<%= pkg.name %>.js'
            }
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            gruntfile: {
                src: 'Gruntfile.js'
            },
            lib: {
                src: ['src/**/*.js']
            },
            test: {
                src: ['test/**/*.js', '!test/lib/**/*.js']
            }
        },
        jscs: {
            gruntfile: {
                src: '<%= jshint.gruntfile.src %>'
            },
            lib: {
                src: ['src/**/*.js', '!src/browser/mq4-hover-shim.js']
            },
            test: {
                src: '<%= jshint.test.src %>'
            }
        },
        eslint: {
            options: {
                config: '.eslintrc'
            },
            gruntfile: {
                src: '<%= jshint.gruntfile.src %>'
            },
            lib: {
                src: ['src/**/*.js', '!src/browser/**/*.js']
            },
            test: {
                src: '<%= jshint.test.src %>'
            }
        },
        nodeunit: {
            files: ['test/**/*_test.js']
        }
    });

    // Tasks
    grunt.registerTask('lint', ['jshint', 'eslint', 'jscs']);
    grunt.registerTask('dist', ['6to5', 'browserify']);
    grunt.registerTask('test', ['lint', 'dist', 'nodeunit']);
    grunt.registerTask('default', ['test']);
};
<commit_msg>enable JSCS for browser-side code<commit_after>/*eslint-env node */

module.exports = function (grunt) {
    'use strict';

    grunt.util.linefeed = '\n';

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

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        banner: (
            "/*!\n * mq4-hover-shim v<%= pkg.version %>\n" +
            " * <%= pkg.homepage %>\n" +
            " * Copyright (c) 2014-2015 Christopher Rebert\n" +
            " * Licensed under the MIT License (https://github.com/twbs/mq4-hover-shim/blob/master/LICENSE).\n" +
            " */\n"
        ),

        '6to5': {
            options: {
                loose: ['es6.modules'],
                modules: "common" // output a CommonJS module
            },
            dist: {
                files: {
                    'dist/cjs/<%= pkg.name %>.js': 'src/browser/<%= pkg.name %>.js'
                }
            }
        },
        browserify: {
            options: {
                banner: '<%= banner %>',
                browserifyOptions: {
                    standalone: 'mq4HoverShim',
                    bundleExternal: false
                }
            },
            dist: {
                src: 'dist/cjs/<%= pkg.name %>.js',
                dest: 'dist/browser/<%= pkg.name %>.js'
            }
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            gruntfile: {
                src: 'Gruntfile.js'
            },
            lib: {
                src: ['src/**/*.js']
            },
            test: {
                src: ['test/**/*.js', '!test/lib/**/*.js']
            }
        },
        jscs: {
            gruntfile: {
                src: '<%= jshint.gruntfile.src %>'
            },
            lib: {
                src: ['src/**/*.js']
            },
            test: {
                src: '<%= jshint.test.src %>'
            }
        },
        eslint: {
            options: {
                config: '.eslintrc'
            },
            gruntfile: {
                src: '<%= jshint.gruntfile.src %>'
            },
            lib: {
                src: ['src/**/*.js', '!src/browser/**/*.js']
            },
            test: {
                src: '<%= jshint.test.src %>'
            }
        },
        nodeunit: {
            files: ['test/**/*_test.js']
        }
    });

    // Tasks
    grunt.registerTask('lint', ['jshint', 'eslint', 'jscs']);
    grunt.registerTask('dist', ['6to5', 'browserify']);
    grunt.registerTask('test', ['lint', 'dist', 'nodeunit']);
    grunt.registerTask('default', ['test']);
};
<|endoftext|>


<commit_before>module.exports = function (grunt) {
  'use strict';

  var initConfig;

  // Loading external tasks
  require('load-grunt-tasks')(grunt);

  // Project configuration.
  initConfig = {
    bower: 'bower_components',
    pkg: grunt.file.readJSON('package.json'),
    watch: {
      test: {
        // Lint & run unit tests in Karma
        // Just running `$ grunt watch` will only lint your code; to run tests
        // on watch, use `$ grunt watch:karma` to start a Karma server first
        tasks: ['jshint', 'karma:unit:run']
      }
    },
    karma: {
      options: {
        configFile: 'test/karma.conf.js',
        browsers: ['PhantomJS']
      },
      unit: {
        singleRun: true
      },
      watch: {
        autoWatch: true
      },
      server: {
        background: true
      }
    },
    jshint: {
      all:[
        'gruntFile.js',
        'angucomplete-alt.js',
        'test/**/*.spec.js'
      ],
      options: {
        jshintrc: '.jshintrc'
      }
    },
    changelog: {
      options: {
        dest: 'CHANGELOG.md'
      }
    },
    uglify: {
      options: {
        mangle: false,
        preserveComments: 'some'
      },
      build: {
        files: {
          'dist/angucomplete-alt.min.js': ['angucomplete-alt.js']
        }
      }
    }
  };

  // Register tasks
  grunt.registerTask('default', ['jshint', 'karma:unit']);
  grunt.registerTask('watch', ['jshint', 'karma:watch']);
  grunt.registerTask('build', ['jshint', 'uglify:build']);

  grunt.initConfig(initConfig);
};

<commit_msg>Remove mangle option from uglify<commit_after>module.exports = function (grunt) {
  'use strict';

  var initConfig;

  // Loading external tasks
  require('load-grunt-tasks')(grunt);

  // Project configuration.
  initConfig = {
    bower: 'bower_components',
    pkg: grunt.file.readJSON('package.json'),
    watch: {
      test: {
        // Lint & run unit tests in Karma
        // Just running `$ grunt watch` will only lint your code; to run tests
        // on watch, use `$ grunt watch:karma` to start a Karma server first
        tasks: ['jshint', 'karma:unit:run']
      }
    },
    karma: {
      options: {
        configFile: 'test/karma.conf.js',
        browsers: ['PhantomJS']
      },
      unit: {
        singleRun: true
      },
      watch: {
        autoWatch: true
      },
      server: {
        background: true
      }
    },
    jshint: {
      all:[
        'gruntFile.js',
        'angucomplete-alt.js',
        'test/**/*.spec.js'
      ],
      options: {
        jshintrc: '.jshintrc'
      }
    },
    changelog: {
      options: {
        dest: 'CHANGELOG.md'
      }
    },
    uglify: {
      options: {
        preserveComments: 'some'
      },
      build: {
        files: {
          'dist/angucomplete-alt.min.js': ['angucomplete-alt.js']
        }
      }
    }
  };

  // Register tasks
  grunt.registerTask('default', ['jshint', 'karma:unit']);
  grunt.registerTask('watch', ['jshint', 'karma:watch']);
  grunt.registerTask('build', ['jshint', 'uglify:build']);

  grunt.initConfig(initConfig);
};

<|endoftext|>


<commit_before>"use strict";

module.exports = function (grunt) {
	var libdir = "bower_components/";

	// A temporary directory used by amdserialize to output the processed modules.
	var tmpdir = "tmp/";

	// The final output directory.
	var outdir = "out/";

	// The grunt.config property populated by amdserialize, containing the
	// list of files to include in the layer.
	var outprop = "amdoutput";

	grunt.initConfig({
		// The loader config should go here.
		amdloader: {
			// Here goes the config for the amd plugins build process.
			baseUrl: "./",

			packages: [
				{name: "dcl", location: libdir + "dcl"},
				{name: "decor", location: libdir + "decor"},
				{name: "delite", location: libdir + "delite"},
				{name: "deliteful", location: libdir + "deliteful"},
				{name: "dojo", location: libdir + "dojo"},
				{name: "dpointer", location: libdir + "dpointer"},
				{name: "dstore", location: libdir + "dstore"},
				{name: "ecma402", location: libdir + "ecma402"},
				{name: "requirejs", location: libdir + "requirejs"},
				{name: "requirejs-domready", location: libdir + "requirejs-domready"},
				{name: "requirejs-dplugins", location: libdir + "requirejs-dplugins"},
				{name: "requirejs-text", location: libdir + "requirejs-text"}
			],

			config: {
				// text should be replace by the module id of text plugin
				text: {
					inlineText: true
				},
				// i18n should be replace by the module id of i18n plugin
				i18n: {
					localesList: ["fr"]
				}
			}
		},

		// The common build config
		amdbuild: {
			// dir is the output directory.
			dir: tmpdir,

			// List of plugins that the build should not try to resolve at build time.
			runtimePlugins: [
				"ecma402/features"
			],

			// List of layers to build.
			layers: [{
				name: "app",
				include: [
					// Modules and layers listed here, and their dependencies, will be added to the layer.
					"app/app"
				],
				includeShallow: [
					// Only the modules listed here (ie. NOT their dependencies) will be added to the layer.
				],
				exclude: [
					// Modules and layers listed here, and their dependencies, will NOT be in the layer.
				],
				excludeShallow: [
					// Only the modules listed here (ie. NOT their dependencies)  will NOT be in the layer.
				]
			}]
		},

		// Config to allow concat to generate the layer.
		concat: {
			options: {
				banner: "<%= " + outprop + ".header%>"
			},
			dist: {
				src: "<%= " + outprop + ".modules.abs %>",
				dest: outdir + "<%= " + outprop + ".layerPath %>"
			}
		},

		// Copy the plugin files to the real output directory.
		copy: {
			dist: {
				expand: true,
				cwd: tmpdir,
				src: "<%= " + outprop + ".plugins.rel %>",
				dest: outdir
			}
		},

		// Erase temp directory and previous build
		clean: {
			erase: [outdir],
			finish: [tmpdir]
		}
	});

	// The main build task.
	grunt.registerTask("amdbuild", function (amdloader) {
		var name = this.name,
			layers = grunt.config(name).layers;

		layers.forEach(function (layer) {
			grunt.task.run("amddepsscan:" + layer.name + ":" + name + ":" + amdloader);
			grunt.task.run("amdserialize:" + layer.name + ":" + name + ":" + amdloader + ":" + outprop);
			grunt.task.run("concat");
			grunt.task.run("copy");
		});
	});

	// Load the plugin that provides the "amd" task.
	grunt.loadNpmTasks("grunt-amd-build");

	// Load vendor plugins.
	grunt.loadNpmTasks("grunt-contrib-concat");
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-clean');

	// Default task.
	grunt.registerTask("default", ["clean:erase", "amdbuild:amdloader", "clean:finish"]);
};
<commit_msg>Copy template files to build dir, explicitly add text module to layer<commit_after>"use strict";

module.exports = function (grunt) {
	var libdir = "bower_components/";

	// A temporary directory used by amdserialize to output the processed modules.
	var tmpdir = "tmp/";

	// The final output directory.
	var outdir = "out/";

	// The grunt.config property populated by amdserialize, containing the
	// list of files to include in the layer.
	var outprop = "amdoutput";

	grunt.initConfig({
		// The loader config should go here.
		amdloader: {
			// Here goes the config for the amd plugins build process.
			baseUrl: "./",

			packages: [
				{name: "dcl", location: libdir + "dcl"},
				{name: "decor", location: libdir + "decor"},
				{name: "delite", location: libdir + "delite"},
				{name: "deliteful", location: libdir + "deliteful"},
				{name: "dojo", location: libdir + "dojo"},
				{name: "dpointer", location: libdir + "dpointer"},
				{name: "dstore", location: libdir + "dstore"},
				{name: "ecma402", location: libdir + "ecma402"},
				{name: "requirejs", location: libdir + "requirejs"},
				{name: "requirejs-domready", location: libdir + "requirejs-domready"},
				{name: "requirejs-dplugins", location: libdir + "requirejs-dplugins"},
				{name: "requirejs-text", location: libdir + "requirejs-text"}
			],

			config: {
				// text should be replace by the module id of text plugin
				text: {
					inlineText: true
				},
				// i18n should be replace by the module id of i18n plugin
				i18n: {
					localesList: ["fr"]
				}
			}
		},

		// The common build config
		amdbuild: {
			// dir is the output directory.
			dir: tmpdir,

			// List of plugins that the build should not try to resolve at build time.
			runtimePlugins: [
				"ecma402/features"
			],

			// List of layers to build.
			layers: [{
				name: "app",
				include: [
					// Modules and layers listed here, and their dependencies, will be added to the layer.
					"app/app",
					"requirejs-text/text"
				],
				includeShallow: [
					// Only the modules listed here (ie. NOT their dependencies) will be added to the layer.
				],
				exclude: [
					// Modules and layers listed here, and their dependencies, will NOT be in the layer.
				],
				excludeShallow: [
					// Only the modules listed here (ie. NOT their dependencies)  will NOT be in the layer.
				]
			}]
		},

		// Config to allow concat to generate the layer.
		concat: {
			options: {
				banner: "<%= " + outprop + ".header%>"
			},
			dist: {
				src: "<%= " + outprop + ".modules.abs %>",
				dest: outdir + "<%= " + outprop + ".layerPath %>"
			}
		},

		// Copy the plugin files to the real output directory.
		copy: {
			dist: {
				expand: true,
				cwd: tmpdir,
				src: "<%= " + outprop + ".plugins.rel %>",
				dest: outdir
			},
			templates: {
				expand: true,
				cwd: libdir,
				src: ["**/*.html", "!**/demos/**", "!**/node_modules/**", "!**/samples/**", "!**/tests/**"],
				dest: outdir
			}
		},

		// Erase temp directory and previous build
		clean: {
			erase: [outdir],
			finish: [tmpdir]
		}
	});

	// The main build task.
	grunt.registerTask("amdbuild", function (amdloader) {
		var name = this.name,
			layers = grunt.config(name).layers;

		layers.forEach(function (layer) {
			grunt.task.run("amddepsscan:" + layer.name + ":" + name + ":" + amdloader);
			grunt.task.run("amdserialize:" + layer.name + ":" + name + ":" + amdloader + ":" + outprop);
			grunt.task.run("concat");
			grunt.task.run("copy");
		});
		grunt.task.run("copy:templates");
	});

	// Load the plugin that provides the "amd" task.
	grunt.loadNpmTasks("grunt-amd-build");

	// Load vendor plugins.
	grunt.loadNpmTasks("grunt-contrib-concat");
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-clean');

	// Default task.
	grunt.registerTask("default", ["clean:erase", "amdbuild:amdloader", "clean:finish"]);
};
<|endoftext|>