Skip to content

Commit

Permalink
Upgrade react datepicker deps (elastic#2160)
Browse files Browse the repository at this point in the history
* working & passing react-datepicker tests

* Upgrade react-datepicker dependencies to patch security flaws in some build & dev tooling
  • Loading branch information
chandlerprall authored and thompsongl committed Sep 10, 2019
1 parent 2a3666c commit 77a57c4
Show file tree
Hide file tree
Showing 5 changed files with 427 additions and 173 deletions.
81 changes: 37 additions & 44 deletions packages/react-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,6 @@ function delay(fn) {

var focusTrap_1 = focusTrap;

var focusTrap$1 = /*#__PURE__*/Object.freeze({
default: focusTrap_1,
__moduleExports: focusTrap_1
});

var createFocusTrap = ( focusTrap$1 && focusTrap_1 ) || focusTrap$1;

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
Expand Down Expand Up @@ -626,7 +619,7 @@ FocusTrap.defaultProps = {
tag: 'div',
paused: false,
focusTrapOptions: {},
_createFocusTrap: createFocusTrap
_createFocusTrap: focusTrap_1
};

var focusTrapReact = FocusTrap;
Expand Down Expand Up @@ -4448,17 +4441,24 @@ var _toInteger = function (it) {
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};

var _toInteger$1 = /*#__PURE__*/Object.freeze({
default: _toInteger,
__moduleExports: _toInteger
});

var toInteger = ( _toInteger$1 && _toInteger ) || _toInteger$1;

// 7.1.15 ToLength

var min = Math.min;
var _toLength = function (it) {
return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
};

var max = Math.max;
var min$1 = Math.min;
var _toAbsoluteIndex = function (index, length) {
index = _toInteger(index);
index = toInteger(index);
return index < 0 ? max(index + length, 0) : min$1(index, length);
};

Expand Down Expand Up @@ -4643,7 +4643,7 @@ var _classCallCheck$1 = unwrapExports(classCallCheck$1);
var _stringAt = function (TO_STRING) {
return function (that, pos) {
var s = String(_defined(that));
var i = _toInteger(pos);
var i = toInteger(pos);
var l = s.length;
var a, b;
if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
Expand Down Expand Up @@ -4813,17 +4813,10 @@ var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORC
return methods;
};

var _iterDefine$1 = /*#__PURE__*/Object.freeze({
default: _iterDefine,
__moduleExports: _iterDefine
});

var require$$0 = ( _iterDefine$1 && _iterDefine ) || _iterDefine$1;

var $at = _stringAt(true);

// 21.1.3.27 String.prototype[@@iterator]()
require$$0(String, 'String', function (iterated) {
_iterDefine(String, 'String', function (iterated) {
this._t = String(iterated); // target
this._i = 0; // next index
// 21.1.5.2.1 %StringIteratorPrototype%.next()
Expand All @@ -4845,7 +4838,7 @@ var _iterStep = function (done, value) {
// 22.1.3.13 Array.prototype.keys()
// 22.1.3.29 Array.prototype.values()
// 22.1.3.30 Array.prototype[@@iterator]()
var es6_array_iterator = require$$0(Array, 'Array', function (iterated, kind) {
var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
this._t = _toIobject(iterated); // target
this._i = 0; // next index
this._k = kind; // kind
Expand Down Expand Up @@ -4886,11 +4879,18 @@ var _wksExt = {

var iterator = _wksExt.f('iterator');

var iterator$1 = createCommonjsModule(function (module) {
module.exports = { "default": iterator, __esModule: true };
var iterator$1 = /*#__PURE__*/Object.freeze({
default: iterator,
__moduleExports: iterator
});

unwrapExports(iterator$1);
var require$$0 = ( iterator$1 && iterator ) || iterator$1;

var iterator$2 = createCommonjsModule(function (module) {
module.exports = { "default": require$$0, __esModule: true };
});

unwrapExports(iterator$2);

var _meta = createCommonjsModule(function (module) {
var META = _uid('meta');
Expand Down Expand Up @@ -5272,30 +5272,23 @@ _wksDefine('observable');

var symbol = _core.Symbol;

var symbol$1 = /*#__PURE__*/Object.freeze({
default: symbol,
__moduleExports: symbol
var symbol$1 = createCommonjsModule(function (module) {
module.exports = { "default": symbol, __esModule: true };
});

var require$$0$1 = ( symbol$1 && symbol ) || symbol$1;

var symbol$2 = createCommonjsModule(function (module) {
module.exports = { "default": require$$0$1, __esModule: true };
});

unwrapExports(symbol$2);
unwrapExports(symbol$1);

var _typeof_1 = createCommonjsModule(function (module, exports) {

exports.__esModule = true;



var _iterator2 = _interopRequireDefault(iterator$1);
var _iterator2 = _interopRequireDefault(iterator$2);



var _symbol2 = _interopRequireDefault(symbol$2);
var _symbol2 = _interopRequireDefault(symbol$1);

var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };

Expand Down Expand Up @@ -5357,9 +5350,16 @@ var _setProto = {
check: check
};

var _setProto$1 = /*#__PURE__*/Object.freeze({
default: _setProto,
__moduleExports: _setProto
});

var require$$0$1 = ( _setProto$1 && _setProto ) || _setProto$1;

// 19.1.3.19 Object.setPrototypeOf(O, proto)

_export(_export.S, 'Object', { setPrototypeOf: _setProto.set });
_export(_export.S, 'Object', { setPrototypeOf: require$$0$1.set });

var setPrototypeOf = _core.Object.setPrototypeOf;

Expand Down Expand Up @@ -7970,21 +7970,14 @@ emptyFunction.thatReturnsArgument = function (arg) {

var emptyFunction_1 = emptyFunction;

var emptyFunction$1 = /*#__PURE__*/Object.freeze({
default: emptyFunction_1,
__moduleExports: emptyFunction_1
});

var emptyFunction$2 = ( emptyFunction$1 && emptyFunction_1 ) || emptyFunction$1;

/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/

var warning = emptyFunction$2;
var warning = emptyFunction_1;

if (process.env.NODE_ENV !== 'production') {
var printWarning = function printWarning(format) {
Expand Down
7 changes: 5 additions & 2 deletions packages/react-datepicker/docs-site/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -57875,10 +57875,13 @@
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
var type = typeof value;
length = length == null ? MAX_SAFE_INTEGER : length;

return !!length &&
(typeof value == 'number' || reIsUint.test(value)) &&
(value > -1 && value % 1 == 0 && value < length);
(type == 'number' ||
(type != 'symbol' && reIsUint.test(value))) &&
(value > -1 && value % 1 == 0 && value < length);
}

module.exports = isIndex;
Expand Down
4 changes: 4 additions & 0 deletions packages/react-datepicker/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ module.exports = function(config) {
test: /\.jsx?$/,
include: path.resolve(__dirname, "src"),
loader: "isparta"
},
{
test: /\.json$/,
loader: "json-loader"
}
]
},
Expand Down
47 changes: 26 additions & 21 deletions packages/react-datepicker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
"license": "MIT",
"homepage": "https://github.com/Hacker0x01/react-datepicker",
"main": "lib",
"files": ["*.md", "dist", "datepicker-lib", "es", "src/stylesheets"],
"files": [
"*.md",
"dist",
"datepicker-lib",
"es",
"src/stylesheets"
],
"resolutions": {
"**/diff": "^3.5.0"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.2",
Expand All @@ -25,8 +34,8 @@
"chai": "^3.5.0",
"cross-env": "^5.1.1",
"css-loader": "^1.0.0",
"enzyme": "^3.1.1",
"enzyme-adapter-react-16": "^1.0.4",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"eslint": "^4.18.2",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
Expand Down Expand Up @@ -56,7 +65,7 @@
"react": "^16.2.0",
"react-docgen": "^2.20.0",
"react-dom": "^16.2.0",
"react-test-renderer": "^16.2.0",
"react-test-renderer": "^16.8.6",
"react-transform-hmr": "^1.0.4",
"rimraf": "^2.6.2",
"rollup": "^0.62.0",
Expand All @@ -81,6 +90,7 @@
"dependencies": {
"classnames": "^2.2.5",
"focus-trap-react": "^4.0.0",
"json-loader": "^0.5.7",
"prop-types": "^15.6.0",
"react-onclickoutside": "^6.7.1",
"react-popper": "^1.0.2"
Expand All @@ -89,31 +99,26 @@
"eslint": "eslint {src,test,docs-site/src}/**/*.{js,jsx} *.js",
"flow": "flow",
"precommit": "lint-staged",
"sass-lint":
"sass-lint --config .sass-lint.yml 'src/stylesheets/*.scss, docs-site/src/*.scss' -i 'docs-site/src/higlight.scss, docs-site/src/reset.scss'",
"sass-lint": "sass-lint --config .sass-lint.yml 'src/stylesheets/*.scss, docs-site/src/*.scss' -i 'docs-site/src/higlight.scss, docs-site/src/reset.scss'",
"lint": "run-p eslint flow sass-lint",
"start": "cross-env MODULES=false node server.js",
"test": "cross-env NODE_ENV=test karma start karma.conf.js --single-run",
"prepublish": "test $(npm -v | tr . '\\n' | head -n 1) -ge '4' || exit 1",
"prepare": "npm run build",
"prebuild": "rimraf es lib dist",
"build": "cross-env NODE_ENV=production run-p build:** && run-p css:**",
"build-dev":
"cross-env NODE_ENV=development run-p build:** && run-p css:**",
"css:prod":
"mkdir -p lib && node-sass --output-style compressed src/stylesheets/datepicker.scss > lib/react-datepicker.min.css",
"css:modules:prod":
"mkdir -p lib && node-sass --output-style compressed src/stylesheets/datepicker-cssmodules.scss > lib/react-datepicker-cssmodules.min.css",
"css:dev":
"mkdir -p lib && node-sass --output-style expanded src/stylesheets/datepicker.scss > lib/react-datepicker.css",
"css:modules:dev":
"mkdir -p lib && node-sass --output-style expanded src/stylesheets/datepicker-cssmodules.scss > lib/react-datepicker-cssmodules.css",
"build:es":
"cross-env BABEL_ENV=cjs rollup -c -i src/index.jsx -o ../react-datepicker.js",
"build:docs":
"cross-env MODULES=false webpack --config webpack.docs.config.js"
"build-dev": "cross-env NODE_ENV=development run-p build:** && run-p css:**",
"css:prod": "mkdir -p lib && node-sass --output-style compressed src/stylesheets/datepicker.scss > lib/react-datepicker.min.css",
"css:modules:prod": "mkdir -p lib && node-sass --output-style compressed src/stylesheets/datepicker-cssmodules.scss > lib/react-datepicker-cssmodules.min.css",
"css:dev": "mkdir -p lib && node-sass --output-style expanded src/stylesheets/datepicker.scss > lib/react-datepicker.css",
"css:modules:dev": "mkdir -p lib && node-sass --output-style expanded src/stylesheets/datepicker-cssmodules.scss > lib/react-datepicker-cssmodules.css",
"build:es": "cross-env BABEL_ENV=cjs rollup -c -i src/index.jsx -o ../react-datepicker.js",
"build:docs": "cross-env MODULES=false webpack --config webpack.docs.config.js"
},
"lint-staged": {
"*.{js,jsx,json,css,scss,md}": ["prettier --write", "git add"]
"*.{js,jsx,json,css,scss,md}": [
"prettier --write",
"git add"
]
}
}
Loading

0 comments on commit 77a57c4

Please sign in to comment.