不要怂,就是干,撸起袖子干!

Commit a1bf8b02 by Sushant Committed by GitHub

Deprecate stuff / Update critical libs (#6945)

* using internal utils to deprecate / warn

* update to validator@6.2.0

* updated wkx@0.4.1
1 parent 4aa0a93a
...@@ -10,6 +10,7 @@ const warnings = {}; ...@@ -10,6 +10,7 @@ const warnings = {};
const Validator = require('./utils/validator-extras').validator; const Validator = require('./utils/validator-extras').validator;
const momentTz = require('moment-timezone'); const momentTz = require('moment-timezone');
const moment = require('moment'); const moment = require('moment');
const Utils = require('./utils');
/** /**
* A convenience class holding commonly used data types. The datatypes are used when defining a new model using `Sequelize.define`, like this: * A convenience class holding commonly used data types. The datatypes are used when defining a new model using `Sequelize.define`, like this:
...@@ -69,7 +70,7 @@ ABSTRACT.prototype.toSql = function toSql() { ...@@ -69,7 +70,7 @@ ABSTRACT.prototype.toSql = function toSql() {
ABSTRACT.warn = function warn(link, text) { ABSTRACT.warn = function warn(link, text) {
if (!warnings[text]) { if (!warnings[text]) {
warnings[text] = true; warnings[text] = true;
console.warn('>> WARNING:', text, '\n>> Check:', link); Utils.warn(`${text}, '\n>> Check:', ${link}`);
} }
}; };
ABSTRACT.prototype.stringify = function stringify(value, options) { ABSTRACT.prototype.stringify = function stringify(value, options) {
......
...@@ -109,7 +109,7 @@ class AbstractQuery { ...@@ -109,7 +109,7 @@ class AbstractQuery {
*/ */
checkLoggingOption() { checkLoggingOption() {
if (this.options.logging === true) { if (this.options.logging === true) {
console.log('DEPRECATION WARNING: The logging-option should be either a function or false. Default: console.log'); Utils.deprecate('The logging-option should be either a function or false. Default: console.log');
this.options.logging = console.log; this.options.logging = console.log;
} }
} }
......
...@@ -1068,7 +1068,7 @@ class Sequelize { ...@@ -1068,7 +1068,7 @@ class Sequelize {
if (options.logging) { if (options.logging) {
if (options.logging === true) { if (options.logging === true) {
console.log('DEPRECATION WARNING: The logging-option should be either a function or false. Default: console.log'); Utils.deprecate('The logging-option should be either a function or false. Default: console.log');
options.logging = console.log; options.logging = console.log;
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
const _ = require('lodash'); const _ = require('lodash');
const util = require('util'); const util = require('util');
const Utils = require('../utils');
function validateDeprecation(value, expectation, options) { function validateDeprecation(value, expectation, options) {
if (!options.deprecated) { if (!options.deprecated) {
...@@ -12,8 +13,7 @@ function validateDeprecation(value, expectation, options) { ...@@ -12,8 +13,7 @@ function validateDeprecation(value, expectation, options) {
if (valid) { if (valid) {
const message = `${util.inspect(value)} should not be of type "${options.deprecated.name}"`; const message = `${util.inspect(value)} should not be of type "${options.deprecated.name}"`;
Utils.deprecate(options.deprecationWarning || message);
console.log('DEPRECATION WARNING:', options.deprecationWarning || message);
} }
return valid; return valid;
......
...@@ -38,7 +38,7 @@ const extensions = { ...@@ -38,7 +38,7 @@ const extensions = {
return !this.regex(str, pattern, modifiers); return !this.regex(str, pattern, modifiers);
}, },
isDecimal(str) { isDecimal(str) {
return str !== '' && !!str.match(/^(?:-?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/); return str !== '' && !!str.match(/^(?:-?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/);
}, },
min(str, val) { min(str, val) {
const number = parseFloat(str); const number = parseFloat(str);
...@@ -81,9 +81,13 @@ validator.notNull = function() { ...@@ -81,9 +81,13 @@ validator.notNull = function() {
throw new Error('Warning "notNull" validation has been deprecated in favor of Schema based "allowNull"'); throw new Error('Warning "notNull" validation has been deprecated in favor of Schema based "allowNull"');
}; };
// https://github.com/chriso/validator.js/blob/1.5.0/lib/validators.js // https://github.com/chriso/validator.js/blob/6.2.0/validator.js
_.forEach(extensions, (extend, key) => { _.forEach(extensions, (extend, key) => {
validator[key] = extend; validator[key] = extend;
}); });
// map isNull to isEmpty
// https://github.com/chriso/validator.js/commit/e33d38a26ee2f9666b319adb67c7fc0d3dea7125
validator.isNull = validator.isEmpty;
exports.validator = validator; exports.validator = validator;
...@@ -47,13 +47,13 @@ ...@@ -47,13 +47,13 @@
"lodash": "^4.17.1", "lodash": "^4.17.1",
"moment": "^2.13.0", "moment": "^2.13.0",
"moment-timezone": "^0.5.4", "moment-timezone": "^0.5.4",
"uuid": "^3.0.0",
"retry-as-promised": "^2.0.0", "retry-as-promised": "^2.0.0",
"semver": "^5.0.1", "semver": "^5.0.1",
"terraformer-wkt-parser": "^1.1.2", "terraformer-wkt-parser": "^1.1.2",
"toposort-class": "^1.0.1", "toposort-class": "^1.0.1",
"validator": "^5.6.0", "uuid": "^3.0.0",
"wkx": "^0.3.0" "validator": "^6.2.0",
"wkx": "^0.4.1"
}, },
"devDependencies": { "devDependencies": {
"chai": "^3.5.0", "chai": "^3.5.0",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!