Skip to content

Commit

Permalink
Merge pull request hapijs#2925 from hapijs/chore/upgrade-modules
Browse files Browse the repository at this point in the history
chore: upgrade modules
  • Loading branch information
Marsup authored Mar 11, 2023
2 parents 227e761 + 9c6c894 commit 6cedc82
Show file tree
Hide file tree
Showing 41 changed files with 444 additions and 375 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
2 changes: 2 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -2727,6 +2727,7 @@ Requires the string value to be a valid domain name.
- `options` - optional settings:
- `allowFullyQualified` - if `true`, domains ending with a `.` character are permitted. Defaults to `false`.
- `allowUnicode` - if `true`, Unicode characters are permitted. Defaults to `true`.
- `allowUnderscore` - if `true`, underscores (`_`) are allowed in the domain name. Defaults to `false`.
- `minDomainSegments` - number of segments required for the domain. Defaults to `2`.
- `maxDomainSegments` - maximum number of allowed domain segments. Default to no limit.
- `tlds` - options for TLD (top level domain) validation. By default, the TLD must be a valid
Expand Down Expand Up @@ -2754,6 +2755,7 @@ Requires the string value to be a valid email address.
- `options` - optional settings:
- `allowFullyQualified` - if `true`, domains ending with a `.` character are permitted. Defaults to `false`.
- `allowUnicode` - if `true`, Unicode characters are permitted. Defaults to `true`.
- `allowUnderscore` - if `true`, underscores (`_`) are allowed in the domain name. Defaults to `false`.
- `ignoreLength` - if `true`, ignore invalid email length errors. Defaults to `false`.
- `minDomainSegments` - number of segments required for the domain. The default setting excludes
single segment domains such as `example@io` which is a valid email but very uncommon. Defaults
Expand Down
1 change: 1 addition & 0 deletions benchmarks/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=true
6 changes: 3 additions & 3 deletions benchmarks/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Fs = require('fs');

const Assert = require('@hapi/hoek/lib/assert');
const { assert } = require('@hapi/hoek');
const Benchmark = require('benchmark');
const Bossy = require('@hapi/bossy');
const Chalk = require('chalk');
Expand Down Expand Up @@ -74,8 +74,8 @@ const test = ([name, initFn, testFn]) => {

const [schema, valid, invalid] = versionPick(initFn)();

Assert(valid === undefined || !testFn(schema, valid).error, 'validation must not fail for: ' + name);
Assert(invalid === undefined || testFn(schema, invalid).error, 'validation must fail for: ' + name);
assert(valid === undefined || !testFn(schema, valid).error, 'validation must not fail for: ' + name);
assert(invalid === undefined || testFn(schema, invalid).error, 'validation must fail for: ' + name);

testFn = versionPick(testFn);
Suite.add(name + (valid !== undefined ? ' (valid)' : ''), () => {
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"full-bench": "npm run bench-update -- --joi @hapi/joi && npm test"
},
"dependencies": {
"@hapi/bossy": "^4.0.3",
"@hapi/hoek": "^6.2.4",
"@hapi/bossy": "^6.0.1",
"@hapi/hoek": "^11.0.2",
"@hapi/joi": "^15.1.0",
"benchmark": "^2.1.4",
"chalk": "^2.4.1",
"cli-table": "^0.3.1",
"cli-table": "^0.3.11",
"d3-format": "^1.3.2",
"joi": "^17.6.4"
"joi": "^17.8.1"
}
}
1 change: 1 addition & 0 deletions browser/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
29 changes: 15 additions & 14 deletions browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@
"scripts": {
"build": "webpack --mode production",
"build-dev": "webpack --mode development",
"build-analyze": "webpack --mode production --profile --json > stats.json",
"build-analyze": "webpack --mode production --stats-optimization-bailout --profile --json > stats.json",
"postbuild-analyze": "webpack-bundle-analyzer stats.json",
"test": "karma start"
},
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/preset-env": "^7.4.5",
"@babel/core": "^7.21.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/preset-env": "^7.20.2",
"@mixer/webpack-bundle-compare": "^0.1.1",
"assert": "^2.0.0",
"babel-loader": "^8.0.6",
"karma": "^4.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-mocha": "^1.3.0",
"karma-sourcemap-loader": "^0.3.7",
"babel-loader": "^9.1.2",
"karma": "^6.4.1",
"karma-chrome-launcher": "^3.1.1",
"karma-mocha": "^2.0.1",
"karma-sourcemap-loader": "^0.4.0",
"karma-webpack": "^5.0.0",
"mocha": "^6.2.0",
"mocha-loader": "^2.0.1",
"util": "^0.12.4",
"webpack": "^5.40.0",
"mocha": "^8.4.0",
"mocha-loader": "^5.1.5",
"util": "^0.12.5",
"webpack": "^5.76.1",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-cli": "^4.7.2"
"webpack-cli": "^5.0.1"
}
}
25 changes: 24 additions & 1 deletion browser/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ describe('Joi', () => {

it('should be able to create schemas', () => {

Joi.string().min(5);
Joi.boolean().truthy('true');
Joi.number().min(5).max(10).multiple(2);
Joi.array().items(Joi.number().required());
Joi.object({
key: Joi.string().required()
});
});

it('should be able to validate data', () => {
Expand All @@ -29,5 +34,23 @@ describe('Joi', () => {
Assert.ok(!schema.validate('test@example.com').error);
Assert.ok(schema.validate('test@example.com ').error);
Assert.ok(!schema.validate('伊昭傑@郵件.商務').error);

const schema2 = Joi.string().email({ tlds: { allow: false } }).required();
Assert.ok(!schema2.validate('test@example.com').error);
Assert.ok(schema2.validate('test@example.com ').error);
Assert.ok(!schema2.validate('伊昭傑@郵件.商務').error);
});

it('validates domain', () => {

const schema = Joi.string().domain().required();
Assert.ok(!schema.validate('example.com').error);
Assert.ok(schema.validate('example.com ').error);
Assert.ok(!schema.validate('example.商務').error);

const schema2 = Joi.string().domain({ tlds: { allow: false } }).required();
Assert.ok(!schema2.validate('example.com').error);
Assert.ok(schema2.validate('example.com ').error);
Assert.ok(!schema2.validate('example.商務').error);
});
});
28 changes: 26 additions & 2 deletions browser/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const Path = require('path');

const Webpack = require('webpack');
const { BundleComparisonPlugin } = require('@mixer/webpack-bundle-compare');


module.exports = {
Expand All @@ -16,6 +17,11 @@ module.exports = {
plugins: [
new Webpack.DefinePlugin({
Buffer: false
}),
new BundleComparisonPlugin({
file: '../stats.msp.gz',
format: 'msgpack',
gzip: true,
})
],
module: {
Expand All @@ -40,10 +46,16 @@ module.exports = {
]
],
plugins: [
'@babel/plugin-proposal-class-properties'
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
]
}
}
},
{
test: /@(hapi|sideway)\//,
sideEffects: false
}
]
},
Expand All @@ -54,7 +66,19 @@ module.exports = {
[Path.join(__dirname, '../lib/manifest.js')]: false,
[Path.join(__dirname, '../lib/trace.js')]: false,
[Path.join(__dirname, '../lib/types/binary.js')]: false,
[Path.join(__dirname, '../node_modules/@sideway/address/lib/tlds.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/tlds/esm/index.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/address/esm/decode.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/bench.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/block.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/contain.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/flatten.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/intersect.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/isPromise.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/escapeHeaderAttribute.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/escapeJson.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/once.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/reachTemplate.js')]: false,
[Path.join(__dirname, '../node_modules/@hapi/hoek/lib/wait.js')]: false,
},
fallback: {
url: false,
Expand Down
4 changes: 2 additions & 2 deletions lib/annotate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const Clone = require('@hapi/hoek/lib/clone');
const { clone } = require('@hapi/hoek');

const Common = require('./common');

Expand All @@ -22,7 +22,7 @@ exports.error = function (stripColorCodes) {
const redBgEscape = stripColorCodes ? '' : '\u001b[41m';
const endColor = stripColorCodes ? '' : '\u001b[0m';

const obj = Clone(this._original);
const obj = clone(this._original);

for (let i = this.details.length - 1; i >= 0; --i) { // Reverse order to process deepest child first
const pos = i + 1;
Expand Down
Loading

0 comments on commit 6cedc82

Please sign in to comment.