Skip to content

Commit

Permalink
THRIFT-4625: Use let/const variable decorators in ES6 Javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
bforbis authored and jeking3 committed Sep 28, 2018
1 parent 98acf18 commit b5d6ea3
Show file tree
Hide file tree
Showing 25 changed files with 1,091 additions and 1,925 deletions.
5 changes: 5 additions & 0 deletions build/docker/ubuntu-artful/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ RUN apt-get install -y --no-install-recommends \
`# Node.js dependencies` \
nodejs

# Test dependencies for running puppeteer
RUN apt-get install -y --no-install-recommends \
`# JS dependencies` \
libxss1

RUN apt-get install -y --no-install-recommends \
`# OCaml dependencies` \
ocaml \
Expand Down
5 changes: 5 additions & 0 deletions build/docker/ubuntu-bionic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ RUN apt-get install -y --no-install-recommends \
`# Node.js dependencies` \
nodejs

# Test dependencies for running puppeteer
RUN apt-get install -y --no-install-recommends \
`# JS dependencies` \
libxss1

RUN apt-get install -y --no-install-recommends \
`# OCaml dependencies` \
ocaml \
Expand Down
9 changes: 8 additions & 1 deletion build/docker/ubuntu-xenial/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /et
# node.js
RUN curl -sL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
echo "deb https://deb.nodesource.com/node_6.x xenial main" | tee /etc/apt/sources.list.d/nodesource.list

### install general dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
`# General dependencies` \
Expand Down Expand Up @@ -190,6 +190,13 @@ RUN apt-get install -y --no-install-recommends \
`# Node.js dependencies` \
nodejs

# Test dependencies for running puppeteer
RUN apt-get install -y --no-install-recommends \
`# JS dependencies` \
libxss1 \
libatk-bridge2.0-0 \
libgtk-3-0

# THRIFT-4517: causes stack overflows; version too old; skip ocaml in xenial
# RUN apt-get install -y --no-install-recommends \
# `# OCaml dependencies` \
Expand Down
277 changes: 153 additions & 124 deletions compiler/cpp/src/thrift/generate/t_js_generator.cc

Large diffs are not rendered by default.

186 changes: 139 additions & 47 deletions lib/js/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -38,7 +39,7 @@ module.exports = function(grunt) {
},
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'
Expand All @@ -47,7 +48,19 @@ module.exports = function(grunt) {
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'
Expand All @@ -58,9 +71,6 @@ module.exports = function(grunt) {
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,
Expand All @@ -71,6 +81,16 @@ module.exports = function(grunt) {
},
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,
Expand All @@ -81,88 +101,151 @@ module.exports = function(grunt) {
},
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');
Expand All @@ -179,16 +262,25 @@ module.exports = function(grunt) {
}, 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']);
};
17 changes: 5 additions & 12 deletions lib/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,12 @@ This reads the package.json and pulls in the appropriate
sources from the internet. To build the JavaScript branch
of Apache Thrift execute the command:

grunt
npx grunt

This runs the grunt build tool, linting all of the source
files, setting up and running the tests, concatenating and
minifying the main libraries and generating the html
documentation.

If grunt is not installed you can install it with npm
like this:

sudo npm install -g grunt-cli
npm install grunt --save-dev

This runs the grunt build tool (from within `./node_modules/.bin/`),
linting all of the source files, setting up and running the
tests, concatenating and minifying the main libraries and
generating the html documentation.

Tree
----
Expand Down
Loading

0 comments on commit b5d6ea3

Please sign in to comment.