blob: 1dcead6505d0cc7a95af0cf8fc171fd325b022e4 [file] [log] [blame]
Henrique Mendonça095ddb72013-09-20 19:38:03 +02001//To build dist/thrift.js, dist/thrift.min.js and doc/*
2//run grunt at the command line in this directory.
3//Prerequisites:
4// Node Setup - nodejs.org
5// Grunt Setup - npm install //reads the ./package.json and installs project dependencies
6
7module.exports = function(grunt) {
8 'use strict';
9
10 grunt.initConfig({
11 pkg: grunt.file.readJSON('package.json'),
12 concat: {
13 options: {
14 separator: ';'
15 },
16 dist: {
17 src: ['src/**/*.js'],
18 dest: 'dist/<%= pkg.name %>.js'
19 }
20 },
21 jsdoc : {
22 dist : {
Roger Meier16fcad02014-03-16 21:12:11 +010023 src: ['src/*.js', './README.md'],
Henrique Mendonça095ddb72013-09-20 19:38:03 +020024 options: {
25 destination: 'doc'
26 }
27 }
28 },
29 uglify: {
30 options: {
31 banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
32 },
33 dist: {
34 files: {
35 'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
36 }
37 }
Henrique Mendonça15d90422015-06-25 22:31:41 +100038 },
henriquea2de4102014-02-07 14:12:56 +010039 shell: {
40 InstallThriftJS: {
Philip Frank5066eb42018-03-07 20:49:25 +010041 command: 'mkdir test/build; mkdir test/build/js; mkdir test/build/js/lib; cp src/thrift.js test/build/js/thrift.js'
henriquea2de4102014-02-07 14:12:56 +010042 },
henrique2a7dccc2014-03-07 22:16:51 +010043 InstallThriftNodeJSDep: {
Nobuaki Sukegawa6defea52015-11-14 17:36:29 +090044 command: 'cd ../..; npm install'
henrique2a7dccc2014-03-07 22:16:51 +010045 },
Philip Frank5066eb42018-03-07 20:49:25 +010046 InstallTestLibs: {
47 command: 'cd test; ant download_jslibs'
48 },
henriquea2de4102014-02-07 14:12:56 +010049 ThriftGen: {
Nobuaki Sukegawa4b7dbe32016-05-25 12:09:02 +090050 command: '../../compiler/cpp/thrift -gen js -gen js:node -o test ../../test/ThriftTest.thrift'
henrique2a7dccc2014-03-07 22:16:51 +010051 },
52 ThriftGenJQ: {
Nobuaki Sukegawa4b7dbe32016-05-25 12:09:02 +090053 command: '../../compiler/cpp/thrift -gen js:jquery -gen js:node -o test ../../test/ThriftTest.thrift'
Henrique Mendonça15d90422015-06-25 22:31:41 +100054 },
55 ThriftGenDeepConstructor: {
Nobuaki Sukegawa4b7dbe32016-05-25 12:09:02 +090056 command: '../../compiler/cpp/thrift -gen js -o test ../../test/JsDeepConstructorTest.thrift'
Philip Frank8fdd6102017-12-06 12:38:05 +010057 },
Ozan Can Altioke46419b2018-03-20 15:02:28 +030058 ThriftGenDoubleConstants: {
59 command: '../../compiler/cpp/thrift -gen js -o test ../../test/DoubleConstantsTest.thrift'
60 },
Philip Frank8fdd6102017-12-06 12:38:05 +010061 ThriftGenES6: {
62 command: '../../compiler/cpp/thrift -gen js -gen js:es6 -o test ../../test/ThriftTest.thrift'
63 },
henriquea2de4102014-02-07 14:12:56 +010064 ThriftTestServer: {
65 options: {
Philip Frank5066eb42018-03-07 20:49:25 +010066 async: true,
67 execOptions: {
68 cwd: "./test",
69 env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
70 }
henriquea2de4102014-02-07 14:12:56 +010071 },
Philip Frank5066eb42018-03-07 20:49:25 +010072 command: "node server_http.js",
henrique2a7dccc2014-03-07 22:16:51 +010073 },
74 ThriftTestServer_TLS: {
75 options: {
Philip Frank5066eb42018-03-07 20:49:25 +010076 async: true,
77 execOptions: {
78 cwd: "./test",
79 env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
80 }
henrique2a7dccc2014-03-07 22:16:51 +010081 },
Philip Frank5066eb42018-03-07 20:49:25 +010082 command: "node server_https.js",
83 },
Henrique Mendonça095ddb72013-09-20 19:38:03 +020084 },
85 qunit: {
henrique2a7dccc2014-03-07 22:16:51 +010086 ThriftJS: {
Henrique Mendonça095ddb72013-09-20 19:38:03 +020087 options: {
88 urls: [
henriquea2de4102014-02-07 14:12:56 +010089 'http://localhost:8088/test-nojq.html'
Henrique Mendonça095ddb72013-09-20 19:38:03 +020090 ]
91 }
henrique2a7dccc2014-03-07 22:16:51 +010092 },
93 ThriftJSJQ: {
94 options: {
95 urls: [
96 'http://localhost:8088/test.html'
97 ]
98 }
99 },
Ozan Can Altioke46419b2018-03-20 15:02:28 +0300100 ThriftJS_DoubleRendering: {
101 options: {
102 '--ignore-ssl-errors': true,
103 urls: [
104 'http://localhost:8088/test-double-rendering.html'
105 ]
106 }
107 },
henrique2a7dccc2014-03-07 22:16:51 +0100108 ThriftWS: {
109 options: {
110 urls: [
111 'http://localhost:8088/testws.html'
112 ]
113 }
114 },
115 ThriftJS_TLS: {
116 options: {
117 '--ignore-ssl-errors': true,
118 urls: [
119 'https://localhost:8089/test-nojq.html'
120 ]
121 }
122 },
123 ThriftJSJQ_TLS: {
124 options: {
125 '--ignore-ssl-errors': true,
126 urls: [
127 'https://localhost:8089/test.html'
128 ]
129 }
130 },
131 ThriftWS_TLS: {
132 options: {
133 '--ignore-ssl-errors': true,
134 urls: [
135 'https://localhost:8089/testws.html'
136 ]
137 }
Henrique Mendonça15d90422015-06-25 22:31:41 +1000138 },
139 ThriftDeepConstructor: {
140 options: {
141 urls: [
142 'http://localhost:8088/test-deep-constructor.html'
143 ]
144 }
Philip Frank8fdd6102017-12-06 12:38:05 +0100145 },
146 ThriftWSES6: {
147 options: {
148 urls: [
149 'http://localhost:8088/test-es6.html'
150 ]
151 }
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200152 }
153 },
154 jshint: {
155 files: ['Gruntfile.js', 'src/**/*.js', 'test/*.js'],
156 options: {
157 // options here to override JSHint defaults
158 globals: {
159 jQuery: true,
160 console: true,
161 module: true,
162 document: true
163 }
164 }
165 },
166 });
167
168 grunt.loadNpmTasks('grunt-contrib-uglify');
169 grunt.loadNpmTasks('grunt-contrib-jshint');
170 grunt.loadNpmTasks('grunt-contrib-qunit');
171 grunt.loadNpmTasks('grunt-contrib-concat');
172 grunt.loadNpmTasks('grunt-jsdoc');
Philip Frank5066eb42018-03-07 20:49:25 +0100173 grunt.loadNpmTasks('grunt-shell-spawn');
174
175 grunt.registerTask('wait', 'Wait just one second for server to start', function () {
176 var done = this.async();
177 setTimeout(function() {
178 done(true);
179 }, 1000);
180 });
Henrique Mendonça095ddb72013-09-20 19:38:03 +0200181
Henrique Mendonça15d90422015-06-25 22:31:41 +1000182 grunt.registerTask('test', ['jshint', 'shell:InstallThriftJS', 'shell:InstallThriftNodeJSDep', 'shell:ThriftGen',
Philip Frank5066eb42018-03-07 20:49:25 +0100183 'shell:InstallTestLibs',
184 'shell:ThriftTestServer', 'shell:ThriftTestServer_TLS',
185 'wait',
Henrique Mendonça15d90422015-06-25 22:31:41 +1000186 'shell:ThriftGenDeepConstructor', 'qunit:ThriftDeepConstructor',
henrique2a7dccc2014-03-07 22:16:51 +0100187 'qunit:ThriftJS', 'qunit:ThriftJS_TLS',
Philip Frank0a84eae2017-12-27 12:54:28 +0100188 'qunit:ThriftWS',
Philip Frank8fdd6102017-12-06 12:38:05 +0100189 'shell:ThriftGenJQ', 'qunit:ThriftJSJQ', 'qunit:ThriftJSJQ_TLS',
Philip Frank5066eb42018-03-07 20:49:25 +0100190 'shell:ThriftGenES6', 'qunit:ThriftWSES6',
191 'shell:ThriftTestServer:kill', 'shell:ThriftTestServer_TLS:kill',
henrique2a7dccc2014-03-07 22:16:51 +0100192 ]);
Philip Frank55ddf192018-01-02 09:00:36 +0100193 grunt.registerTask('default', ['test', 'concat', 'uglify', 'jsdoc']);
henriquea2de4102014-02-07 14:12:56 +0100194};