From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/jaegertracing/thrift/lib/ts/Gruntfile.js | 163 +++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 src/jaegertracing/thrift/lib/ts/Gruntfile.js (limited to 'src/jaegertracing/thrift/lib/ts/Gruntfile.js') diff --git a/src/jaegertracing/thrift/lib/ts/Gruntfile.js b/src/jaegertracing/thrift/lib/ts/Gruntfile.js new file mode 100644 index 000000000..fcd79f8e5 --- /dev/null +++ b/src/jaegertracing/thrift/lib/ts/Gruntfile.js @@ -0,0 +1,163 @@ +//To build dist/thrift.js, dist/thrift.min.js and doc/* +//run grunt at the command line in this directory. +//Prerequisites: +// Node Setup - nodejs.org +// Grunt Setup - npm install //reads the ./package.json and installs project dependencies +// Run grunt - npx grunt // uses project-local installed version of grunt (from package.json) + +module.exports = function(grunt) { + 'use strict'; + + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + concat: { + options: { + separator: ';' + }, + dist: { + src: ['src/**/*.js'], + dest: 'dist/<%= pkg.name %>.js' + } + }, + shell: { + InstallThriftJS: { + command: 'mkdir -p test/build/ts/lib; cp ../js/src/thrift.js test/build/ts/thrift.js' + }, + InstallThriftNodeJSDep: { + command: 'cd ../..; npm install' + }, + InstallTestLibs: { + command: 'cd test; ant download_jslibs' + }, + ThriftGen: { + command: [ + 'mkdir -p test/gen-js', + '../../compiler/cpp/thrift -gen js:ts --out test/gen-js ../../test/ThriftTest.thrift', + 'mkdir -p test/gen-nodejs', + '../../compiler/cpp/thrift -gen js:node,ts --out test/gen-nodejs ../../test/ThriftTest.thrift', + ].join(' && ') + }, + ThriftBrowserifyNodeInt64: { + command: [ + './node_modules/browserify/bin/cmd.js ./node_modules/node-int64/Int64.js -s Int64 -o test/build/js/lib/Int64.js', + './node_modules/browserify/bin/cmd.js ../nodejs/lib/thrift/int64_util.js -s Int64Util -o test/build/js/lib/Int64Util.js', + './node_modules/browserify/bin/cmd.js ./node_modules/json-int64/index.js -s JSONInt64 -o test/build/js/lib/JSONInt64.js' + ].join(' && ') + }, + ThriftGenInt64: { + command: '../../compiler/cpp/thrift -gen js:ts -o test ../../test/Int64Test.thrift' + }, + ThriftTestServer: { + options: { + async: true, + execOptions: { + cwd: "./test", + env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"} + } + }, + command: "node server_http.js", + }, + BuildTS: { + options: { + execOptions: { + cwd: "./test", + } + }, + command : "../node_modules/typescript/bin/tsc --listFiles --outDir build/ts" + }, + BrowserifyCompiledTS: { + command: [ + "./node_modules/browserify/bin/cmd.js test/build/ts/test.js -o test/build/ts/lib/test.js --standalone test", + "./node_modules/browserify/bin/cmd.js test/build/ts/test-int64.js -o test/build/ts/lib/test-int64.js --standalone testInt64", + ].join(" && ") + }, + InstallGeneratedCode: { + command: [ + "mkdir -p test/build/ts", + "cp -r test/gen-js test/build/ts" + ].join(" && ") + }, + }, + qunit: { + ThriftJS: { + options: { + urls: [ + 'http://localhost:8089/test.html' + ], + puppeteer: { + headless: true, + args: ['--no-sandbox'], + }, + } + }, + ThriftJS_Int64: { + options: { + urls: [ + 'http://localhost:8089/test-int64.html' + ], + puppeteer: { + headless: true, + args: ['--no-sandbox'], + ignoreHTTPSErrors: true, + }, + } + }, + }, + jshint: { + // The main Thrift library file. not es6 yet :( + lib: { + src: ['../js/src/**/*.js'], + }, + // The test files use es6 + test: { + src: ['Gruntfile.js', 'test/*.js'], + options: { + esversion: 6, + } + }, + gen_js_code: { + src: ['test/gen-js/*.js'], + }, + gen_node_code: { + src: ['test/gen-nodejs/*.js'], + options: { + node: true, + } + }, + }, + }); + + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-qunit'); + grunt.loadNpmTasks('grunt-shell-spawn'); + + grunt.registerTask('wait', 'Wait just one second for the server to start', function () { + var done = this.async(); + setTimeout(function() { + done(true); + }, 1000); + }); + + grunt.registerTask('installAndGenerate', [ + 'shell:InstallThriftJS', + 'shell:InstallThriftNodeJSDep', + 'shell:ThriftGen', + 'shell:ThriftBrowserifyNodeInt64', + 'shell:ThriftGenInt64', + 'shell:InstallTestLibs', + 'shell:BuildTS', + 'shell:InstallGeneratedCode', + 'shell:BrowserifyCompiledTS', + ]); + + grunt.registerTask('test', [ + 'installAndGenerate', + 'jshint', + 'shell:ThriftTestServer', + 'wait', + 'qunit:ThriftJS', + 'qunit:ThriftJS_Int64', + 'shell:ThriftTestServer:kill', + ]); + grunt.registerTask('default', ['test']); +}; -- cgit v1.2.3