2014-11-18 15:06:25 +01:00
|
|
|
'use strict';
|
2014-11-18 14:54:52 +01:00
|
|
|
module.exports = function (grunt) {
|
|
|
|
grunt.initConfig({
|
|
|
|
clean: {
|
|
|
|
main: {
|
2015-01-27 11:23:16 +01:00
|
|
|
src: ['coverage', 'playground/**/*.rt.js']
|
2014-11-18 14:54:52 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
eslint: {
|
|
|
|
all: {
|
|
|
|
src: [
|
2014-11-18 15:06:25 +01:00
|
|
|
'src/**/*.js', 'playground/**/*.js',
|
2015-01-20 08:43:59 +01:00
|
|
|
'test/src/**/*.js',
|
2014-12-08 11:45:32 +01:00
|
|
|
'!playground/libs/**/*.js',
|
2014-12-31 15:41:11 +01:00
|
|
|
'!playground/dist/**/*.js',
|
2014-12-02 13:35:20 +01:00
|
|
|
'!playground/**/*.rt.js'
|
2014-11-18 14:54:52 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
jasmine_node: {
|
|
|
|
options: {
|
|
|
|
forceExit: true,
|
|
|
|
match: '.',
|
|
|
|
matchall: false,
|
|
|
|
specNameMatcher: 'spec',
|
|
|
|
extensions: 'js'
|
|
|
|
},
|
|
|
|
all: ['server/test'],
|
|
|
|
grunt: ['conf/tasks/test']
|
|
|
|
},
|
|
|
|
browserify: {
|
2014-12-07 14:12:50 +01:00
|
|
|
rt: {
|
2014-12-03 17:44:57 +01:00
|
|
|
files: {
|
2014-12-28 10:52:06 +01:00
|
|
|
'playground/dist/rt-main.browser.js': ['playground/rt-main.js']
|
2014-12-03 17:44:57 +01:00
|
|
|
},
|
|
|
|
options: {
|
|
|
|
transform: ['brfs'],
|
|
|
|
alias: ['react:react/addons']
|
2014-12-02 15:57:18 +01:00
|
|
|
}
|
2014-11-18 14:54:52 +01:00
|
|
|
}
|
2014-12-01 21:39:59 +01:00
|
|
|
},
|
|
|
|
node_tap: {
|
|
|
|
default_options: {
|
|
|
|
options: {
|
|
|
|
outputType: 'tap',
|
|
|
|
outputTo: 'console'
|
|
|
|
},
|
|
|
|
files: {
|
2014-12-02 13:35:20 +01:00
|
|
|
tests: ['./test/src/*.js']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
rt: {
|
|
|
|
files: [
|
2014-12-30 09:42:31 +01:00
|
|
|
'playground/*.rt'
|
2014-12-02 13:35:20 +01:00
|
|
|
],
|
|
|
|
tasks: ['rt'],
|
|
|
|
options: {
|
|
|
|
spawn: false
|
|
|
|
}
|
2015-02-12 09:04:36 +01:00
|
|
|
},
|
|
|
|
test: {
|
|
|
|
files: [
|
|
|
|
'src/**/*.*', 'test/**/*.*'
|
|
|
|
],
|
|
|
|
tasks: ['test'],
|
|
|
|
options: {
|
|
|
|
spawn: false
|
|
|
|
}
|
2014-12-01 21:39:59 +01:00
|
|
|
}
|
2014-12-25 11:13:07 +01:00
|
|
|
},
|
|
|
|
uglify: {
|
|
|
|
my_target: {
|
|
|
|
//options: {
|
|
|
|
// sourceMap: true,
|
|
|
|
// sourceMapIncludeSources: true,
|
|
|
|
// sourceMapIn: 'example/coffeescript-sourcemap.js', // input sourcemap from a previous compilation
|
|
|
|
//},
|
|
|
|
files: {
|
2014-12-28 10:52:06 +01:00
|
|
|
'playground/dist/rt-main.browser.min.js': ['playground/dist/rt-main.browser.js'],
|
2014-12-25 11:13:07 +01:00
|
|
|
'playground/libs/requirejs-plugins/text.min.js': ['playground/libs/requirejs-plugins/text.js'],
|
|
|
|
'playground/libs/requirejs-plugins/json.min.js': ['playground/libs/requirejs-plugins/json.js']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
requirejs: {
|
|
|
|
compile: {
|
2015-01-01 09:19:50 +01:00
|
|
|
options: readConfig('./home.config.js')
|
2014-12-30 16:53:42 +01:00
|
|
|
},
|
|
|
|
playground: {
|
2015-01-04 16:09:26 +01:00
|
|
|
options: readConfig('./playground.config.js')
|
2014-12-25 11:13:07 +01:00
|
|
|
}
|
2014-11-18 14:54:52 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-01-01 09:19:50 +01:00
|
|
|
function readConfig(file) {
|
2015-04-16 15:45:22 +02:00
|
|
|
return eval(require('fs').readFileSync(file).toString()); // eslint-disable-line no-eval
|
2015-01-01 09:19:50 +01:00
|
|
|
}
|
|
|
|
|
2015-01-22 15:57:48 +01:00
|
|
|
grunt.task.loadTasks('./internalTasks');
|
2014-11-18 14:54:52 +01:00
|
|
|
grunt.loadNpmTasks('grunt-browserify');
|
2014-12-02 13:35:20 +01:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
2014-12-25 11:13:07 +01:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-requirejs');
|
2014-11-18 15:06:25 +01:00
|
|
|
grunt.loadNpmTasks('grunt-eslint');
|
2014-12-01 21:39:59 +01:00
|
|
|
grunt.loadNpmTasks('grunt-node-tap');
|
2014-12-25 11:13:07 +01:00
|
|
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
2014-11-18 14:54:52 +01:00
|
|
|
|
2014-12-31 17:31:57 +01:00
|
|
|
grunt.registerTask('default', ['eslint:all']);
|
2014-12-02 13:35:20 +01:00
|
|
|
grunt.registerTask('test', ['node_tap']);
|
|
|
|
|
|
|
|
grunt.registerTask('rt', function () {
|
|
|
|
var reactTemplates = require('./src/cli');
|
2014-12-03 10:36:34 +01:00
|
|
|
var files = grunt.file.expand('playground/*.rt');
|
2014-12-28 10:47:34 +01:00
|
|
|
var conf = {modules: 'amd', force: true, _: files};
|
2014-12-07 14:12:50 +01:00
|
|
|
var ret = reactTemplates.execute(conf);
|
2014-12-02 13:35:20 +01:00
|
|
|
return ret === 0;
|
|
|
|
});
|
2014-11-18 14:54:52 +01:00
|
|
|
|
2014-12-02 13:35:20 +01:00
|
|
|
grunt.registerTask('build', ['rt', 'browserify:pg']);
|
2014-12-02 15:57:18 +01:00
|
|
|
grunt.registerTask('home', ['rt', 'browserify:home']);
|
2015-01-05 09:07:27 +01:00
|
|
|
grunt.registerTask('pgall', ['rt', 'browserify', 'uglify', 'requirejs']);
|
2014-11-18 14:54:52 +01:00
|
|
|
|
2014-12-02 13:35:20 +01:00
|
|
|
grunt.registerTask('all', ['default', 'test']);
|
2014-11-18 14:54:52 +01:00
|
|
|
};
|