]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/js/Gruntfile.js
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / js / Gruntfile.js
CommitLineData
f67539c2
TL
1//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// Run grunt - npx grunt // uses project-local installed version of grunt (from package.json)
7
8module.exports = function(grunt) {
9 'use strict';
10
11 grunt.initConfig({
12 pkg: grunt.file.readJSON('package.json'),
13 concat: {
14 options: {
15 separator: ';'
16 },
17 dist: {
18 src: ['src/**/*.js'],
19 dest: 'dist/<%= pkg.name %>.js'
20 }
21 },
22 jsdoc : {
23 dist : {
24 src: ['src/*.js', './README.md'],
25 options: {
26 destination: 'doc'
27 }
28 }
29 },
30 uglify: {
31 options: {
32 banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
33 },
34 dist: {
35 files: {
36 'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
37 }
38 }
39 },
40 shell: {
41 InstallThriftJS: {
42 command: 'mkdir -p test/build/js/lib; cp src/thrift.js test/build/js/thrift.js'
43 },
44 InstallThriftNodeJSDep: {
45 command: 'cd ../..; npm install'
46 },
47 InstallTestLibs: {
48 command: 'cd test; ant download_jslibs'
49 },
50 ThriftGen: {
51 command: [
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',
63 ].join(' && ')
64 },
65 ThriftGenJQ: {
66 command: '../../compiler/cpp/thrift -gen js:jquery -gen js:node -o test ../../test/ThriftTest.thrift'
67 },
68 ThriftGenDeepConstructor: {
69 command: '../../compiler/cpp/thrift -gen js -o test ../../test/JsDeepConstructorTest.thrift'
70 },
71 ThriftBrowserifyNodeInt64: {
72 command: [
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'
76 ].join(' && ')
77 },
78 ThriftGenInt64: {
79 command: '../../compiler/cpp/thrift -gen js -o test ../../test/Int64Test.thrift'
80 },
81 ThriftGenDoubleConstants: {
82 command: '../../compiler/cpp/thrift -gen js -o test ../../test/DoubleConstantsTest.thrift'
83 },
84 ThriftTestServer: {
85 options: {
86 async: true,
87 execOptions: {
88 cwd: "./test",
89 env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
90 }
91 },
92 command: "node server_http.js",
93 },
94 ThriftTestServerES6: {
95 options: {
96 async: true,
97 execOptions: {
98 cwd: "./test",
99 env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
100 }
101 },
102 command: "node server_http.js --es6",
103 },
104 ThriftTestServer_TLS: {
105 options: {
106 async: true,
107 execOptions: {
108 cwd: "./test",
109 env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
110 }
111 },
112 command: "node server_https.js",
113 },
114 ThriftTestServerES6_TLS: {
115 options: {
116 async: true,
117 execOptions: {
118 cwd: "./test",
119 env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
120 }
121 },
122 command: "node server_https.js --es6",
123 },
124 },
125 qunit: {
126 ThriftJS: {
127 options: {
128 urls: [
129 'http://localhost:8089/test-nojq.html'
130 ],
131 puppeteer: {
132 headless: true,
133 args: ['--no-sandbox'],
134 },
135 }
136 },
137 ThriftJSJQ: {
138 options: {
139 urls: [
140 'http://localhost:8089/test.html'
141 ],
142 puppeteer: {
143 headless: true,
144 args: ['--no-sandbox'],
145 },
146 }
147 },
148 ThriftJS_DoubleRendering: {
149 options: {
150 urls: [
151 'http://localhost:8089/test-double-rendering.html'
152 ],
153 puppeteer: {
154 headless: true,
155 args: ['--no-sandbox'],
156 ignoreHTTPSErrors: true,
157 },
158 }
159 },
160 ThriftJS_Int64: {
161 options: {
162 urls: [
163 'http://localhost:8089/test-int64.html'
164 ],
165 puppeteer: {
166 headless: true,
167 args: ['--no-sandbox'],
168 ignoreHTTPSErrors: true,
169 },
170 }
171 },
172 ThriftWS: {
173 options: {
174 urls: [
175 'http://localhost:8089/testws.html'
176 ],
177 puppeteer: {
178 headless: true,
179 args: ['--no-sandbox'],
180 },
181 }
182 },
183 ThriftJS_TLS: {
184 options: {
185 urls: [
186 'https://localhost:8091/test-nojq.html'
187 ],
188 puppeteer: {
189 headless: true,
190 args: ['--no-sandbox'],
191 ignoreHTTPSErrors: true,
192 },
193 }
194 },
195 ThriftJSJQ_TLS: {
196 options: {
197 urls: [
198 'https://localhost:8091/test.html'
199 ],
200 puppeteer: {
201 headless: true,
202 args: ['--no-sandbox'],
203 ignoreHTTPSErrors: true,
204 },
205 }
206 },
207 ThriftWS_TLS: {
208 options: {
209 urls: [
210 'https://localhost:8091/testws.html'
211 ],
212 puppeteer: {
213 headless: true,
214 args: ['--no-sandbox'],
215 ignoreHTTPSErrors: true,
216 },
217 }
218 },
219 ThriftDeepConstructor: {
220 options: {
221 urls: [
222 'http://localhost:8089/test-deep-constructor.html'
223 ],
224 puppeteer: {
225 headless: true,
226 args: ['--no-sandbox'],
227 },
228 }
229 },
230 ThriftWSES6: {
231 options: {
232 urls: [
233 'http://localhost:8088/test-es6.html'
234 ],
235 puppeteer: {
236 headless: true,
237 args: ['--no-sandbox'],
238 },
239 }
240 }
241 },
242 jshint: {
243 // The main Thrift library file. not es6 yet :(
244 lib: {
245 src: ['src/**/*.js'],
246 },
247 // The test files use es6
248 test: {
249 src: ['Gruntfile.js', 'test/*.js'],
250 options: {
251 esversion: 6,
252 }
253 },
254 gen_js_code: {
255 src: ['test/gen-js/*.js', 'test/gen-js-jquery/*.js'],
256 },
257 gen_es6_code: {
258 src: ['test/gen-js-es6/*.js'],
259 options: {
260 esversion: 6,
261 }
262 },
263 gen_node_code: {
264 src: ['test/gen-nodejs/*.js'],
265 options: {
266 node: true,
267 }
268 },
269 gen_node_es6_code: {
270 src: ['test/gen-nodejs-es6/*.js'],
271 options: {
272 node: true,
273 esversion: 6,
274 }
275 }
276 },
277 });
278
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');
285
286 grunt.registerTask('wait', 'Wait just one second for the server to start', function () {
287 var done = this.async();
288 setTimeout(function() {
289 done(true);
290 }, 1000);
291 });
292
293 grunt.registerTask('installAndGenerate', [
294 'shell:InstallThriftJS',
295 'shell:InstallThriftNodeJSDep',
296 'shell:ThriftGen',
297 'shell:ThriftGenDeepConstructor',
298 'shell:ThriftGenDoubleConstants',
299 'shell:InstallTestLibs',
300 'shell:ThriftBrowserifyNodeInt64',
301 'shell:ThriftGenInt64'
302 ]);
303
304 grunt.registerTask('test', [
305 'installAndGenerate',
306 'jshint',
307 'shell:ThriftTestServer',
308 'shell:ThriftTestServer_TLS',
309 'shell:ThriftTestServerES6',
310 'shell:ThriftTestServerES6_TLS',
311 'wait',
312 'qunit:ThriftDeepConstructor',
313 'qunit:ThriftJS',
314 'qunit:ThriftJS_TLS',
315 'qunit:ThriftJS_DoubleRendering',
316 'qunit:ThriftWS',
317 'qunit:ThriftJSJQ',
318 'qunit:ThriftJSJQ_TLS',
319 'qunit:ThriftWSES6',
320 'qunit:ThriftJS_Int64',
321 'shell:ThriftTestServer:kill',
322 'shell:ThriftTestServer_TLS:kill',
323 'shell:ThriftTestServerES6:kill',
324 'shell:ThriftTestServerES6_TLS:kill',
325 ]);
326 grunt.registerTask('default', ['test', 'concat', 'uglify', 'jsdoc']);
327};