Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: npm packages to latest versions #472

Merged
merged 13 commits into from
Nov 9, 2017
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@
"String": "string"
}
}
],
"prefer-destructuring": [
"error",
{
"object": true,
"array": false
}
]
},
"settings": {
Expand Down
2 changes: 0 additions & 2 deletions build/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ module.exports = (config) => config.set({

frameworks: [
'mocha',
'sinon-stub-promise',
'chai-sinon',
'chai-as-promised',
'chai-dom',
'chai',
'sinon',
Expand Down
2 changes: 1 addition & 1 deletion build/webpack.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const webpack = require('webpack');
const I18nPlugin = require('i18n-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

const DefinePlugin = webpack.DefinePlugin;
const { DefinePlugin } = webpack;
const NormalPlugin = webpack.NormalModuleReplacementPlugin;

/* eslint-disable global-require */
Expand Down
7 changes: 3 additions & 4 deletions build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ const isDev = process.env.NODE_ENV === 'dev';
const path = require('path');
const commonConfig = require('./webpack.common.config');
const RsyncPlugin = require('./RsyncPlugin');
const UglifyJsPlugin = require('webpack').optimize.UglifyJsPlugin;
const { UglifyJsPlugin } = require('webpack').optimize;
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const BannerPlugin = require('webpack').BannerPlugin;
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const { BannerPlugin } = require('webpack');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const version = isRelease ? require('../package.json').version : 'dev';
const fs = require('fs');
const license = require('./license');
Expand Down
5 changes: 2 additions & 3 deletions build/webpack.karma.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
require('babel-polyfill');

const merge = require('deepmerge');
const IgnorePlugin = require('webpack').IgnorePlugin;
const { IgnorePlugin } = require('webpack');
const commonConfig = require('./webpack.common.config');

const baseConfig = commonConfig('en-US');

const config = merge(baseConfig, {
const config = Object.assign(baseConfig, {
devtool: 'inline-source-map',
resolve: {
alias: {
Expand Down
24 changes: 16 additions & 8 deletions functional-tests/base-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const webdriver = require('selenium-webdriver');
const expect = require('chai').expect;
const { expect } = require('chai');

describe('Base Test', () => {
before(() => {
if (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
this.browser = new webdriver.Builder()
.usingServer(`http://${process.env.SAUCE_USERNAME}:${process.env.SAUCE_ACCESS_KEY}@ondemand.saucelabs.com:80/wd/hub`)
.usingServer(
`http://${process.env.SAUCE_USERNAME}:${
process.env.SAUCE_ACCESS_KEY
}@ondemand.saucelabs.com:80/wd/hub`
)
.withCapabilities({
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
build: process.env.TRAVIS_BUILD_NUMBER,
Expand All @@ -15,15 +19,17 @@ describe('Base Test', () => {
chromeOptions: {
args: ['--disable-web-security']
}
}).build();
})
.build();
} else {
this.browser = new webdriver.Builder()
.withCapabilities({
browserName: 'chrome',
chromeOptions: {
args: ['--disable-web-security']
}
}).build();
})
.build();
}
});

Expand All @@ -36,10 +42,12 @@ describe('Base Test', () => {
});

it('should load a file', () => {
return this.browser.wait(webdriver.until.elementLocated(webdriver.By.className('bp-loaded')), 5000).then((element) => {
this.browser.wait(webdriver.until.elementIsVisible(element), 5000).then((el) => {
expect(el).to.not.equal(undefined);
return this.browser
.wait(webdriver.until.elementLocated(webdriver.By.className('bp-loaded')), 5000)
.then((element) => {
this.browser.wait(webdriver.until.elementIsVisible(element), 5000).then((el) => {
expect(el).to.not.equal(undefined);
});
});
});
});
});
79 changes: 39 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,46 @@
"url": "git@github.com:box/box-content-preview.git"
},
"devDependencies": {
"@commitlint/cli": "^3.2.0",
"@commitlint/cli": "^4.2.2",
"autobind-decorator": "^1.3.4",
"autoprefixer": "^7.1.4",
"babel-core": "^6.25.0",
"babel-eslint": "^8.0.1",
"autoprefixer": "^7.1.6",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.2",
"babel-loader": "^7.1.2",
"babel-plugin-istanbul": "^4.1.4",
"babel-plugin-transform-class-properties": "^6.23.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-require-ignore": "0.1.1",
"babel-plugin-transform-require-ignore": "^0.1.1",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-es2016": "^6.22.0",
"babel-preset-react": "^6.23.0",
"box-annotations": "^0.2.1",
"chai": "^3.5.0",
"chai-as-promised": "5.3.0",
"chai": "^4.1.2",
"chai-dom": "^1.5.0",
"conventional-changelog-cli": "^1.3.2",
"conventional-github-releaser": "^1.1.12",
"conventional-changelog-cli": "^1.3.4",
"conventional-github-releaser": "^2.0.0",
"create-react-class": "^15.6.2",
"css-loader": "^0.28.7",
"cssnano-cli": "^1.0.5",
"deepmerge": "^1.5.0",
"eslint": "^4.7.2",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-prettier": "^2.6.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.7.0",
"eslint-import-resolver-webpack": "^0.8.3",
"eslint-plugin-babel": "^4.1.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0",
"extract-text-webpack-plugin": "3.0.0",
"fetch-mock": "^5.12.1",
"extract-text-webpack-plugin": "3.0.2",
"fetch-mock": "^5.13.1",
"fetch-mock-forwarder": "^1.0.0",
"file-loader": "^0.11.2",
"file-loader": "^1.1.5",
"husky": "^0.14.3",
"i18n-webpack-plugin": "^1.0.0",
"jsuri": "^1.3.1",
"karma": "^1.5.0",
"karma-chai": "^0.1.0",
"karma-chai-as-promised": "^0.1.2",
"karma-chai-dom": "^1.1.0",
"karma-chai-sinon": "^0.1.5",
"karma-chrome-launcher": "^2.2.0",
Expand All @@ -60,42 +57,40 @@
"karma-html2js-preprocessor": "^1.1.0",
"karma-junit-reporter": "^1.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.2",
"karma-mocha-reporter": "^2.2.5",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sinon": "^1.0.5",
"karma-sinon-stub-promise": "^1.0.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.4",
"lint-staged": "^4.2.3",
"karma-webpack": "^2.0.5",
"lint-staged": "^4.3.0",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"mocha": "^3.4.2",
"mocha": "^4.0.1",
"mock-local-storage": "^1.0.2",
"mojito-rb-gen": "^0.0.1",
"node-noop": "^1.0.0",
"node-sass": "^4.5.0",
"node-sass": "^4.6.0",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"phantomjs-prebuilt": "^2.1.14",
"postcss-loader": "^2.0.6",
"prettier": "^1.5.3",
"prettier-eslint-cli": "^4.1.1",
"phantomjs-prebuilt": "^2.1.16",
"postcss-loader": "^2.0.8",
"prettier": "^1.8.1",
"prettier-eslint-cli": "^4.4.0",
"raw-loader": "^0.5.1",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-virtualized": "^9.9.0",
"react-virtualized": "^9.12.0",
"sass-loader": "^6.0.6",
"selenium-webdriver": "^3.5.0",
"selenium-webdriver": "^3.6.0",
"sinon": "^1.17.7",
"sinon-chai": "2.13.0",
"sinon-stub-promise": "^4.0.0",
"sinon-chai": "2.14.0",
"string-replace-loader": "^1.3.0",
"style-loader": "^0.18.2",
"stylelint": "^8.1.1",
"style-loader": "^0.19.0",
"stylelint": "^8.2.0",
"stylelint-config-standard": "^17.0.0",
"stylelint-order": "^0.7.0",
"stylelint-scss": "^2.1.0",
"webpack": "^3.6.0",
"webpack": "^3.8.1",
"webpack-bundle-analyzer": "^2.8.3",
"whatwg-fetch": "^2.0.3"
},
Expand All @@ -116,7 +111,7 @@
"prettier": "prettier-eslint \"src/lib/**/*.js\" --print-width 120 --single-quote --tab-width 4 --write",
"prod": "BABEL_ENV=production NODE_ENV=production node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js --progress --colors --config build/webpack.config.js",
"release": "yarn run clean && yarn run build-rb && yarn run lint && yarn run test && yarn run prod",
"test": "NODE_ENV=test ./node_modules/.bin/karma start build/karma.conf.js",
"test": "NODE_ENV=test node --max_old_space_size=4096 ./node_modules/.bin/karma start build/karma.conf.js",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can tell if we have a memory leak? Or is this just a reasonable amount of memory to run tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a temporary solution while we look into ways to optimize the unit tests. We shouldn't be hitting this limit (especially after annotations has been removed). I'm going to go through the tests and verify that they're all being cleaned up properly.

"upgrade-pdfjs": "./build/upgrade_pdfjs.sh && ./build/minify_pdfjs.sh",
"upgrade-annotations": "./build/upgrade_annotations.sh",
"watch": "BABEL_ENV=dev NODE_ENV=dev ./node_modules/.bin/webpack --watch --progress --colors --config build/webpack.config.js",
Expand All @@ -125,10 +120,14 @@
"patch": "./build/release.sh -p"
},
"lint-staged": {
"src/lib/**/*.js": [
"prettier-eslint --print-width 120 --single-quote --tab-width 4 --write",
"git add"
]
"functional-tests/*.js": [
"prettier-eslint --print-width 120 --single-quote --tab-width 4 --write",
"git add"
],
"src/lib/**/*.js": [
"prettier-eslint --print-width 120 --single-quote --tab-width 4 --write",
"git add"
]
},
"dependencies": {}
}
2 changes: 1 addition & 1 deletion src/lib/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const EXT_STANDARD_DERIVATIVES = 'OES_standard_derivatives';
const EXT_LOSE_CONTEXT = 'WEBGL_lose_context';
const EVENT_WEBGL_CONEXT_LOST = 'webglcontextlost';

let userAgent = navigator.userAgent;
let { userAgent } = navigator;
let name;
let gl;
let supportsWebGL;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/PageControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ class PageControls extends EventEmitter {
* @return {void}
*/
pageNumInputBlurHandler(event) {
const target = event.target;
const { target } = event;
const pageNumber = parseInt(target.value, 10);

if (!isNaN(pageNumber)) {
if (!Number.isNaN(pageNumber)) {
this.emit('pagechange', pageNumber);
}

Expand Down
5 changes: 2 additions & 3 deletions src/lib/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ class Popup {
* @return {void}
*/
addContent(element, prepend) {
const contentEl = this.contentEl;
if (prepend) {
contentEl.insertBefore(element, contentEl.firstChild);
this.contentEl.insertBefore(element, this.contentEl.firstChild);
} else {
contentEl.appendChild(element);
this.contentEl.appendChild(element);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ class Preview extends EventEmitter {
* @return {void}
*/
keydownHandler(event) {
const target = event.target;
const { target } = event;

// If keyboard shortcuts / hotkeys are disabled, ignore
if (!this.options.useHotkeys) {
Expand Down
12 changes: 10 additions & 2 deletions src/lib/__tests__/tokens-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ describe('lib/tokens', () => {

describe('getTokens', () => {
it('should throw an error when no id provided', () => {
return getTokens(null, 'token').should.be.rejectedWith(Error);
return getTokens(null, 'token')
.then(() => Assert.fail())
.catch((err) => {
expect(err).to.be.an('error');
});
});
it('should use undefined token when no token provided', () => {
return getTokens('123').then((data) => {
Expand Down Expand Up @@ -90,7 +94,11 @@ describe('lib/tokens', () => {
});
});
it('should throw an error when not all tokens could be fetched', () => {
return getTokens(['123', '456', '789'], mapIdTokenFunction).should.be.rejectedWith(Error);
return getTokens(['123', '456', '789'], mapIdTokenFunction)
.then(() => Assert.fail())
.catch((err) => {
expect(err).to.be.an('error');
});
});
});
});
11 changes: 5 additions & 6 deletions src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,7 @@ export function createContentUrl(template, asset) {
* @return {Function} Factory for creating asset url
*/
export function createAssetUrlCreator(location) {
const baseURI = location.baseURI;
const staticBaseURI = location.staticBaseURI;
const { baseURI, staticBaseURI } = location;

return (name) => {
let asset;
Expand Down Expand Up @@ -437,7 +436,7 @@ export function createAssetUrlCreator(location) {
* @return {void}
*/
export function prefetchAssets(urls) {
const head = document.head;
const { head } = document;

urls.forEach((url) => {
if (!head.querySelector(`link[rel="prefetch"][href="${url}"]`)) {
Expand All @@ -454,7 +453,7 @@ export function prefetchAssets(urls) {
* @return {void}
*/
export function loadStylesheets(urls) {
const head = document.head;
const { head } = document;

urls.forEach((url) => {
if (!head.querySelector(`link[rel="stylesheet"][href="${url}"]`)) {
Expand All @@ -471,7 +470,7 @@ export function loadStylesheets(urls) {
* @return {Promise} Promise to load scripts
*/
export function loadScripts(urls) {
const head = document.head;
const { head } = document;
const promises = [];

urls.forEach((url) => {
Expand Down Expand Up @@ -580,7 +579,7 @@ export function findScriptLocation(name, script) {
const anchor = document.createElement('a');
anchor.href = scriptSrc;

const pathname = anchor.pathname;
const { pathname } = anchor;
const pathFragments = pathname.split('/');
const fragmentLength = pathFragments.length;
const fileName = pathFragments[fragmentLength - 1];
Expand Down
2 changes: 1 addition & 1 deletion src/lib/viewers/box3d/Box3DViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class Box3DViewer extends BaseViewer {
this.prefetchAssets(JS);
}

const representation = this.options.representation;
const { representation } = this.options;
if (content && this.isRepresentationReady(representation)) {
const template = representation.content.url_template;
get(this.createContentUrl(template, 'entities.json'), this.appendAuthHeader(), 'any');
Expand Down
Loading