THRIFT-4625: Use let/const variable decorators in ES6 Javascript
diff --git a/lib/js/Gruntfile.js b/lib/js/Gruntfile.js
index 1dcead6..fd290d2 100644
--- a/lib/js/Gruntfile.js
+++ b/lib/js/Gruntfile.js
@@ -3,6 +3,7 @@
//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';
@@ -38,7 +39,7 @@
},
shell: {
InstallThriftJS: {
- command: 'mkdir test/build; mkdir test/build/js; mkdir test/build/js/lib; cp src/thrift.js test/build/js/thrift.js'
+ command: 'mkdir -p test/build/js/lib; cp src/thrift.js test/build/js/thrift.js'
},
InstallThriftNodeJSDep: {
command: 'cd ../..; npm install'
@@ -47,7 +48,19 @@
command: 'cd test; ant download_jslibs'
},
ThriftGen: {
- command: '../../compiler/cpp/thrift -gen js -gen js:node -o test ../../test/ThriftTest.thrift'
+ command: [
+ 'mkdir -p test/gen-js',
+ '../../compiler/cpp/thrift -gen js --out test/gen-js ../../test/ThriftTest.thrift',
+ '../../compiler/cpp/thrift -gen js --out test/gen-js ../../test/JsDeepConstructorTest.thrift',
+ 'mkdir -p test/gen-js-jquery',
+ '../../compiler/cpp/thrift -gen js:jquery --out test/gen-js-jquery ../../test/ThriftTest.thrift',
+ 'mkdir -p test/gen-nodejs',
+ '../../compiler/cpp/thrift -gen js:node --out test/gen-nodejs ../../test/ThriftTest.thrift',
+ 'mkdir -p test/gen-js-es6',
+ '../../compiler/cpp/thrift -gen js:es6 --out test/gen-js-es6 ../../test/ThriftTest.thrift',
+ 'mkdir -p test/gen-nodejs-es6',
+ '../../compiler/cpp/thrift -gen js:node,es6 --out ./test/gen-nodejs-es6 ../../test/ThriftTest.thrift',
+ ].join(' && ')
},
ThriftGenJQ: {
command: '../../compiler/cpp/thrift -gen js:jquery -gen js:node -o test ../../test/ThriftTest.thrift'
@@ -58,9 +71,6 @@
ThriftGenDoubleConstants: {
command: '../../compiler/cpp/thrift -gen js -o test ../../test/DoubleConstantsTest.thrift'
},
- ThriftGenES6: {
- command: '../../compiler/cpp/thrift -gen js -gen js:es6 -o test ../../test/ThriftTest.thrift'
- },
ThriftTestServer: {
options: {
async: true,
@@ -71,6 +81,16 @@
},
command: "node server_http.js",
},
+ ThriftTestServerES6: {
+ options: {
+ async: true,
+ execOptions: {
+ cwd: "./test",
+ env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
+ }
+ },
+ command: "node server_http.js --es6",
+ },
ThriftTestServer_TLS: {
options: {
async: true,
@@ -81,88 +101,151 @@
},
command: "node server_https.js",
},
+ ThriftTestServerES6_TLS: {
+ options: {
+ async: true,
+ execOptions: {
+ cwd: "./test",
+ env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
+ }
+ },
+ command: "node server_https.js --es6",
+ },
},
qunit: {
ThriftJS: {
options: {
urls: [
- 'http://localhost:8088/test-nojq.html'
- ]
+ 'http://localhost:8089/test-nojq.html'
+ ],
+ puppeteer: {
+ headless: true,
+ args: ['--no-sandbox'],
+ },
}
},
ThriftJSJQ: {
options: {
urls: [
- 'http://localhost:8088/test.html'
- ]
+ 'http://localhost:8089/test.html'
+ ],
+ puppeteer: {
+ headless: true,
+ args: ['--no-sandbox'],
+ },
}
},
ThriftJS_DoubleRendering: {
options: {
- '--ignore-ssl-errors': true,
urls: [
- 'http://localhost:8088/test-double-rendering.html'
- ]
+ 'http://localhost:8089/test-double-rendering.html'
+ ],
+ puppeteer: {
+ headless: true,
+ args: ['--no-sandbox'],
+ ignoreHTTPSErrors: true,
+ },
}
},
ThriftWS: {
options: {
urls: [
- 'http://localhost:8088/testws.html'
- ]
+ 'http://localhost:8089/testws.html'
+ ],
+ puppeteer: {
+ headless: true,
+ args: ['--no-sandbox'],
+ },
}
},
ThriftJS_TLS: {
options: {
- '--ignore-ssl-errors': true,
urls: [
- 'https://localhost:8089/test-nojq.html'
- ]
+ 'https://localhost:8091/test-nojq.html'
+ ],
+ puppeteer: {
+ headless: true,
+ args: ['--no-sandbox'],
+ ignoreHTTPSErrors: true,
+ },
}
},
ThriftJSJQ_TLS: {
options: {
- '--ignore-ssl-errors': true,
urls: [
- 'https://localhost:8089/test.html'
- ]
+ 'https://localhost:8091/test.html'
+ ],
+ puppeteer: {
+ headless: true,
+ args: ['--no-sandbox'],
+ ignoreHTTPSErrors: true,
+ },
}
},
ThriftWS_TLS: {
options: {
- '--ignore-ssl-errors': true,
urls: [
- 'https://localhost:8089/testws.html'
- ]
+ 'https://localhost:8091/testws.html'
+ ],
+ puppeteer: {
+ headless: true,
+ args: ['--no-sandbox'],
+ ignoreHTTPSErrors: true,
+ },
}
},
ThriftDeepConstructor: {
options: {
urls: [
- 'http://localhost:8088/test-deep-constructor.html'
- ]
+ 'http://localhost:8089/test-deep-constructor.html'
+ ],
+ puppeteer: {
+ headless: true,
+ args: ['--no-sandbox'],
+ },
}
},
ThriftWSES6: {
options: {
urls: [
'http://localhost:8088/test-es6.html'
- ]
+ ],
+ puppeteer: {
+ headless: true,
+ args: ['--no-sandbox'],
+ },
}
}
},
jshint: {
- files: ['Gruntfile.js', 'src/**/*.js', 'test/*.js'],
- options: {
- // options here to override JSHint defaults
- globals: {
- jQuery: true,
- console: true,
- module: true,
- document: true
+ // The main thrift library file. not es6 yet :(
+ lib: {
+ src: ['src/**/*.js'],
+ options: {
+ // options here to override JSHint defaults
+ globals: {
+ jQuery: true,
+ console: true,
+ module: true,
+ document: true,
+ },
}
- }
- },
+ },
+ // The test files use es6
+ test: {
+ src: ['Gruntfile.js', 'test/*.js'],
+ options: {
+ // options here to override JSHint defaults
+ globals: {
+ jQuery: true,
+ console: true,
+ module: true,
+ document: true,
+ },
+ esversion: 6,
+ }
+ },
+ }
});
grunt.loadNpmTasks('grunt-contrib-uglify');
@@ -179,16 +262,25 @@
}, 1000);
});
- grunt.registerTask('test', ['jshint', 'shell:InstallThriftJS', 'shell:InstallThriftNodeJSDep', 'shell:ThriftGen',
- 'shell:InstallTestLibs',
- 'shell:ThriftTestServer', 'shell:ThriftTestServer_TLS',
- 'wait',
- 'shell:ThriftGenDeepConstructor', 'qunit:ThriftDeepConstructor',
- 'qunit:ThriftJS', 'qunit:ThriftJS_TLS',
- 'qunit:ThriftWS',
- 'shell:ThriftGenJQ', 'qunit:ThriftJSJQ', 'qunit:ThriftJSJQ_TLS',
- 'shell:ThriftGenES6', 'qunit:ThriftWSES6',
- 'shell:ThriftTestServer:kill', 'shell:ThriftTestServer_TLS:kill',
- ]);
+ grunt.registerTask('installAndGenerate', [
+ 'shell:InstallThriftJS', 'shell:InstallThriftNodeJSDep', 'shell:ThriftGen',
+ 'shell:ThriftGenDeepConstructor',
+ 'shell:InstallTestLibs',
+ ]);
+
+ grunt.registerTask('test', [
+ 'jshint',
+ 'installAndGenerate',
+ 'shell:ThriftTestServer', 'shell:ThriftTestServer_TLS',
+ 'shell:ThriftTestServerES6', 'shell:ThriftTestServerES6_TLS',
+ 'wait',
+ 'qunit:ThriftDeepConstructor',
+ 'qunit:ThriftJS', 'qunit:ThriftJS_TLS',
+ 'qunit:ThriftWS',
+ 'qunit:ThriftJSJQ', 'qunit:ThriftJSJQ_TLS',
+ 'qunit:ThriftWSES6',
+ 'shell:ThriftTestServer:kill', 'shell:ThriftTestServer_TLS:kill',
+ 'shell:ThriftTestServerES6:kill', 'shell:ThriftTestServerES6_TLS:kill',
+ ]);
grunt.registerTask('default', ['test', 'concat', 'uglify', 'jsdoc']);
};