1 //To build dist/thrift.js, dist/thrift.min.js and doc/*
2 //run grunt at the command line in this directory.
4 // Node Setup - nodejs.org
5 // Grunt Setup - npm install //reads the ./package.json and installs project dependencies
6 // Run grunt - npx grunt // uses project-local installed version of grunt (from package.json)
8 module
.exports = function(grunt
) {
12 pkg
: grunt
.file
.readJSON('package.json'),
19 dest
: 'dist/<%= pkg.name %>.js'
24 src
: ['src/*.js', './README.md'],
32 banner
: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
36 'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
42 command
: 'mkdir -p test/build/js/lib; cp src/thrift.js test/build/js/thrift.js'
44 InstallThriftNodeJSDep
: {
45 command
: 'cd ../..; npm install'
48 command
: 'cd test; ant download_jslibs'
52 'mkdir -p test/gen-js',
53 '../../compiler/cpp/thrift -gen js --out test/gen-js ../../test/ThriftTest.thrift',
54 '../../compiler/cpp/thrift -gen js --out test/gen-js ../../test/JsDeepConstructorTest.thrift',
55 'mkdir -p test/gen-js-jquery',
56 '../../compiler/cpp/thrift -gen js:jquery --out test/gen-js-jquery ../../test/ThriftTest.thrift',
57 'mkdir -p test/gen-nodejs',
58 '../../compiler/cpp/thrift -gen js:node --out test/gen-nodejs ../../test/ThriftTest.thrift',
59 'mkdir -p test/gen-js-es6',
60 '../../compiler/cpp/thrift -gen js:es6 --out test/gen-js-es6 ../../test/ThriftTest.thrift',
61 'mkdir -p test/gen-nodejs-es6',
62 '../../compiler/cpp/thrift -gen js:node,es6 --out ./test/gen-nodejs-es6 ../../test/ThriftTest.thrift',
66 command
: '../../compiler/cpp/thrift -gen js:jquery -gen js:node -o test ../../test/ThriftTest.thrift'
68 ThriftGenDeepConstructor
: {
69 command
: '../../compiler/cpp/thrift -gen js -o test ../../test/JsDeepConstructorTest.thrift'
71 ThriftBrowserifyNodeInt64
: {
73 './node_modules/browserify/bin/cmd.js ./node_modules/node-int64/Int64.js -s Int64 -o test/build/js/lib/Int64.js',
74 './node_modules/browserify/bin/cmd.js ../nodejs/lib/thrift/int64_util.js -s Int64Util -o test/build/js/lib/Int64Util.js',
75 './node_modules/browserify/bin/cmd.js ./node_modules/json-int64/index.js -s JSONInt64 -o test/build/js/lib/JSONInt64.js'
79 command
: '../../compiler/cpp/thrift -gen js -o test ../../test/Int64Test.thrift'
81 ThriftGenDoubleConstants
: {
82 command
: '../../compiler/cpp/thrift -gen js -o test ../../test/DoubleConstantsTest.thrift'
89 env
: {NODE_PATH
: "../../nodejs/lib:../../../node_modules"}
92 command
: "node server_http.js",
94 ThriftTestServerES6
: {
99 env
: {NODE_PATH
: "../../nodejs/lib:../../../node_modules"}
102 command
: "node server_http.js --es6",
104 ThriftTestServer_TLS
: {
109 env
: {NODE_PATH
: "../../nodejs/lib:../../../node_modules"}
112 command
: "node server_https.js",
114 ThriftTestServerES6_TLS
: {
119 env
: {NODE_PATH
: "../../nodejs/lib:../../../node_modules"}
122 command
: "node server_https.js --es6",
129 'http://localhost:8089/test-nojq.html'
133 args
: ['--no-sandbox'],
140 'http://localhost:8089/test.html'
144 args
: ['--no-sandbox'],
148 ThriftJS_DoubleRendering
: {
151 'http://localhost:8089/test-double-rendering.html'
155 args
: ['--no-sandbox'],
156 ignoreHTTPSErrors
: true,
163 'http://localhost:8089/test-int64.html'
167 args
: ['--no-sandbox'],
168 ignoreHTTPSErrors
: true,
175 'http://localhost:8089/testws.html'
179 args
: ['--no-sandbox'],
186 'https://localhost:8091/test-nojq.html'
190 args
: ['--no-sandbox'],
191 ignoreHTTPSErrors
: true,
198 'https://localhost:8091/test.html'
202 args
: ['--no-sandbox'],
203 ignoreHTTPSErrors
: true,
210 'https://localhost:8091/testws.html'
214 args
: ['--no-sandbox'],
215 ignoreHTTPSErrors
: true,
219 ThriftDeepConstructor
: {
222 'http://localhost:8089/test-deep-constructor.html'
226 args
: ['--no-sandbox'],
233 'http://localhost:8088/test-es6.html'
237 args
: ['--no-sandbox'],
243 // The main Thrift library file. not es6 yet :(
245 src
: ['src/**/*.js'],
247 // The test files use es6
249 src
: ['Gruntfile.js', 'test/*.js'],
255 src
: ['test/gen-js/*.js', 'test/gen-js-jquery/*.js'],
258 src
: ['test/gen-js-es6/*.js'],
264 src
: ['test/gen-nodejs/*.js'],
270 src
: ['test/gen-nodejs-es6/*.js'],
279 grunt
.loadNpmTasks('grunt-contrib-uglify');
280 grunt
.loadNpmTasks('grunt-contrib-jshint');
281 grunt
.loadNpmTasks('grunt-contrib-qunit');
282 grunt
.loadNpmTasks('grunt-contrib-concat');
283 grunt
.loadNpmTasks('grunt-jsdoc');
284 grunt
.loadNpmTasks('grunt-shell-spawn');
286 grunt
.registerTask('wait', 'Wait just one second for the server to start', function () {
287 var done
= this.async();
288 setTimeout(function() {
293 grunt
.registerTask('installAndGenerate', [
294 'shell:InstallThriftJS',
295 'shell:InstallThriftNodeJSDep',
297 'shell:ThriftGenDeepConstructor',
298 'shell:ThriftGenDoubleConstants',
299 'shell:InstallTestLibs',
300 'shell:ThriftBrowserifyNodeInt64',
301 'shell:ThriftGenInt64'
304 grunt
.registerTask('test', [
305 'installAndGenerate',
307 'shell:ThriftTestServer',
308 'shell:ThriftTestServer_TLS',
309 'shell:ThriftTestServerES6',
310 'shell:ThriftTestServerES6_TLS',
312 'qunit:ThriftDeepConstructor',
314 'qunit:ThriftJS_TLS',
315 'qunit:ThriftJS_DoubleRendering',
318 'qunit:ThriftJSJQ_TLS',
320 'qunit:ThriftJS_Int64',
321 'shell:ThriftTestServer:kill',
322 'shell:ThriftTestServer_TLS:kill',
323 'shell:ThriftTestServerES6:kill',
324 'shell:ThriftTestServerES6_TLS:kill',
326 grunt
.registerTask('default', ['test', 'concat', 'uglify', 'jsdoc']);