Skip to content

Commit 482ef10

Browse files
authored
chore!: bump joi to v17 (#5973)
1 parent f5359bd commit 482ef10

File tree

7 files changed

+121
-64
lines changed

7 files changed

+121
-64
lines changed

docs/migrations/migrate-from-v4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ Please consider switching to ESLint. You can check out [`tslint-to-eslint-config
7474
#### `@vue/cli-shared-utils`
7575

7676
* Bump [chalk](https://github.com/chalk/chalk) from v2 to v4
77+
* Bump [joi](https://github.com/sideway/joi) from v15 (used to be `@hapi/joi`) to v17

packages/@vue/cli-service/lib/options.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,39 @@ const schema = createSchema(joi => joi.object({
99
runtimeCompiler: joi.boolean(),
1010
transpileDependencies: joi.array(),
1111
productionSourceMap: joi.boolean(),
12-
parallel: joi.alternatives().try([
12+
parallel: joi.alternatives().try(
1313
joi.boolean(),
1414
joi.number().integer()
15-
]),
15+
),
1616
devServer: joi.object(),
1717
pages: joi.object().pattern(
1818
/\w+/,
19-
joi.alternatives().try([
19+
joi.alternatives().try(
2020
joi.string().required(),
2121
joi.array().items(joi.string().required()),
2222

2323
joi.object().keys({
24-
entry: joi.alternatives().try([
24+
entry: joi.alternatives().try(
2525
joi.string().required(),
2626
joi.array().items(joi.string().required())
27-
]).required()
27+
).required()
2828
}).unknown(true)
29-
])
29+
)
3030
),
31-
crossorigin: joi.string().valid(['', 'anonymous', 'use-credentials']),
31+
crossorigin: joi.string().valid('', 'anonymous', 'use-credentials'),
3232
integrity: joi.boolean(),
3333

3434
// css
3535
css: joi.object({
36-
// TODO: deprecate this after joi 16 release
37-
modules: joi.boolean(),
36+
modules:
37+
joi.boolean()
38+
.warning('deprecate.error', {
39+
message: 'Please use `css.requireModuleExtension` instead.'
40+
})
41+
.message({
42+
'deprecate.error':
43+
'The {#label} option in vue.config.js is deprecated. {#message}'
44+
}),
3845
requireModuleExtension: joi.boolean(),
3946
extract: joi.alternatives().try(joi.boolean(), joi.object()),
4047
sourceMap: joi.boolean(),
@@ -56,7 +63,7 @@ const schema = createSchema(joi => joi.object({
5663
),
5764

5865
// known runtime options for built-in plugins
59-
lintOnSave: joi.any().valid([true, false, 'error', 'warning', 'default']),
66+
lintOnSave: joi.any().valid(true, false, 'error', 'warning', 'default'),
6067
pwa: joi.object(),
6168

6269
// 3rd party plugin options
Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
const { exit } = require('./exit')
22

33
// proxy to joi for option validation
4-
exports.createSchema = fn => fn(require('@hapi/joi'))
4+
exports.createSchema = fn => {
5+
const joi = require('joi')
6+
7+
let schema = fn(joi)
8+
if (typeof schema === 'object' && typeof schema.validate !== 'function') {
9+
schema = joi.object(schema)
10+
}
11+
12+
return schema
13+
}
514

615
exports.validate = (obj, schema, cb) => {
7-
require('@hapi/joi').validate(obj, schema, {}, err => {
8-
if (err) {
9-
cb(err.message)
10-
if (process.env.VUE_CLI_TEST) {
11-
throw err
12-
} else {
13-
exit(1)
14-
}
16+
const { error } = schema.validate(obj)
17+
if (error) {
18+
cb(error.details[0].message)
19+
20+
if (process.env.VUE_CLI_TEST) {
21+
throw error
22+
} else {
23+
exit(1)
1524
}
16-
})
25+
}
1726
}
1827

1928
exports.validateSync = (obj, schema) => {
20-
const result = require('@hapi/joi').validate(obj, schema)
21-
if (result.error) {
22-
throw result.error
29+
const { error } = schema.validate(obj)
30+
if (error) {
31+
throw error
2332
}
2433
}

packages/@vue/cli-shared-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"homepage": "https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-shared-utils#readme",
2222
"dependencies": {
23-
"@hapi/joi": "^15.0.1",
23+
"joi": "^17.2.1",
2424
"chalk": "^4.1.0",
2525
"execa": "^1.0.0",
2626
"launch-editor": "^2.2.1",

packages/@vue/cli-ui/apollo-server/api/task.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const schema = joi => ({
1818
})
1919

2020
const describeSchema = createSchema(joi => ({
21-
match: joi.alternatives().try(joi.object().type(RegExp), joi.func()).required().description('Match a npm script command'),
21+
match: joi.alternatives().try(joi.object().instance(RegExp), joi.func()).required().description('Match a npm script command'),
2222
...schema(joi)
2323
}))
2424

packages/@vue/cli/lib/options.js

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,52 @@ const { createSchema, validate } = require('@vue/cli-shared-utils/lib/validate')
77

88
const rcPath = exports.rcPath = getRcPath('.vuerc')
99

10-
const presetSchema = createSchema(joi => joi.object().keys({
11-
vueVersion: joi.string().only(['2', '3']),
12-
bare: joi.boolean(),
13-
useConfigFiles: joi.boolean(),
14-
// TODO: Use warn for router and vuex once @hapi/joi v16 releases
15-
router: joi.boolean(),
16-
routerHistoryMode: joi.boolean(),
17-
vuex: joi.boolean(),
18-
cssPreprocessor: joi.string().only(['sass', 'dart-sass', 'node-sass', 'less', 'stylus']),
19-
plugins: joi.object().required(),
20-
configs: joi.object()
21-
}))
10+
const presetSchema = createSchema((joi) =>
11+
joi
12+
.object()
13+
.keys({
14+
vueVersion: joi.string().valid('2', '3'),
15+
bare: joi.boolean(),
16+
useConfigFiles: joi.boolean(),
17+
router: joi
18+
.boolean()
19+
.warning('deprecate.error', {
20+
message: 'Please use @vue/cli-plugin-router instead.'
21+
})
22+
.message({
23+
'deprecate.error':
24+
'The {#label} option in preset is deprecated. {#message}'
25+
}),
26+
routerHistoryMode: joi
27+
.boolean()
28+
.warning('deprecate.error', {
29+
message: 'Please use @vue/cli-plugin-router instead.'
30+
})
31+
.message({
32+
'deprecate.error':
33+
'The {#label} option in preset is deprecated. {#message}'
34+
}),
35+
vuex: joi
36+
.boolean()
37+
.warning('deprecate.error', {
38+
message: 'Please use @vue/cli-plugin-vuex instead.'
39+
})
40+
.message({
41+
'deprecate.error':
42+
'The {#label} option in preset is deprecated. {#message}'
43+
}),
44+
cssPreprocessor: joi
45+
.string()
46+
.valid('sass', 'dart-sass', 'node-sass', 'less', 'stylus'),
47+
plugins: joi.object().required(),
48+
configs: joi.object()
49+
})
50+
)
2251

2352
const schema = createSchema(joi => joi.object().keys({
2453
latestVersion: joi.string().regex(/^\d+\.\d+\.\d+(-(alpha|beta|rc)\.\d+)?$/),
2554
lastChecked: joi.date().timestamp(),
26-
packageManager: joi.string().only(['yarn', 'npm', 'pnpm']),
55+
packageManager: joi.string().valid('yarn', 'npm', 'pnpm'),
2756
useTaobaoRegistry: joi.boolean(),
2857
presets: joi.object().pattern(/^/, presetSchema)
2958
}))

yarn.lock

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@
11751175
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.1.0.tgz#6c9eafc78c1529248f8f4d92b0799a712b6052c6"
11761176
integrity sha512-i9YbZPN3QgfighY/1X1Pu118VUz2Fmmhd6b2n0/O8YVgGGfw0FbUYoA97k7FkpGJ+pLCFEDLUmAPPV4D1kpeFw==
11771177

1178-
"@hapi/joi@^15.0.0", "@hapi/joi@^15.0.1":
1178+
"@hapi/joi@^15.0.0":
11791179
version "15.1.1"
11801180
resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-15.1.1.tgz#c675b8a71296f02833f8d6d243b34c57b8ce19d7"
11811181
integrity sha512-entf8ZMOK8sc+8YfeOlM8pCfg3b5+WZIKBfUaaJT8UsjAAPjartzxIYm3TIbjvA4u+u++KbcXD38k682nVHDAQ==
@@ -5640,7 +5640,7 @@ buffer@^4.3.0:
56405640
ieee754 "^1.1.4"
56415641
isarray "^1.0.0"
56425642

5643-
buffer@^5.1.0, buffer@^5.2.1, buffer@^5.5.0, buffer@^5.6.0:
5643+
buffer@^5.2.1, buffer@^5.5.0, buffer@^5.6.0:
56445644
version "5.7.1"
56455645
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0"
56465646
integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==
@@ -6713,13 +6713,13 @@ component-emitter@^1.2.1:
67136713
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
67146714
integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==
67156715

6716-
compress-commons@^4.0.0:
6717-
version "4.0.1"
6718-
resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-4.0.1.tgz#c5fa908a791a0c71329fba211d73cd2a32005ea8"
6719-
integrity sha512-xZm9o6iikekkI0GnXCmAl3LQGZj5TBDj0zLowsqi7tJtEa3FMGSEcHcqrSJIrOAk1UG/NBbDn/F1q+MG/p/EsA==
6716+
compress-commons@^4.0.2:
6717+
version "4.0.2"
6718+
resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-4.0.2.tgz#d6896be386e52f37610cef9e6fa5defc58c31bd7"
6719+
integrity sha512-qhd32a9xgzmpfoga1VQEiLEwdKZ6Plnpx5UCgIsf89FSolyJ7WnifY4Gtjgv5WR6hWAyRaHxC5MiEhU/38U70A==
67206720
dependencies:
67216721
buffer-crc32 "^0.2.13"
6722-
crc32-stream "^4.0.0"
6722+
crc32-stream "^4.0.1"
67236723
normalize-path "^3.0.0"
67246724
readable-stream "^3.6.0"
67256725

@@ -7113,20 +7113,21 @@ cosmiconfig@^6.0.0:
71137113
path-type "^4.0.0"
71147114
yaml "^1.7.2"
71157115

7116-
crc32-stream@^4.0.0:
7117-
version "4.0.0"
7118-
resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-4.0.0.tgz#05b7ca047d831e98c215538666f372b756d91893"
7119-
integrity sha512-tyMw2IeUX6t9jhgXI6um0eKfWq4EIDpfv5m7GX4Jzp7eVelQ360xd8EPXJhp2mHwLQIkqlnMLjzqSZI3a+0wRw==
7116+
crc-32@^1.2.0:
7117+
version "1.2.0"
7118+
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.0.tgz#cb2db6e29b88508e32d9dd0ec1693e7b41a18208"
7119+
integrity sha512-1uBwHxF+Y/4yF5G48fwnKq6QsIXheor3ZLPT80yGBV1oEUwpPojlEhQbWKVw1VwcTQyMGHK1/XMmTjmlsmTTGA==
71207120
dependencies:
7121-
crc "^3.4.4"
7122-
readable-stream "^3.4.0"
7121+
exit-on-epipe "~1.0.1"
7122+
printj "~1.1.0"
71237123

7124-
crc@^3.4.4:
7125-
version "3.8.0"
7126-
resolved "https://registry.yarnpkg.com/crc/-/crc-3.8.0.tgz#ad60269c2c856f8c299e2c4cc0de4556914056c6"
7127-
integrity sha512-iX3mfgcTMIq3ZKLIsVFAbv7+Mc10kxabAGQb8HvjA1o3T1PIYprbakQ65d3I+2HGHt6nSKkM9PYjgoJO2KcFBQ==
7124+
crc32-stream@^4.0.1:
7125+
version "4.0.1"
7126+
resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-4.0.1.tgz#0f047d74041737f8a55e86837a1b826bd8ab0067"
7127+
integrity sha512-FN5V+weeO/8JaXsamelVYO1PHyeCsuL3HcG4cqsj0ceARcocxalaShCsohZMSAF+db7UYFwBy1rARK/0oFItUw==
71287128
dependencies:
7129-
buffer "^5.1.0"
7129+
crc-32 "^1.2.0"
7130+
readable-stream "^3.4.0"
71307131

71317132
create-ecdh@^4.0.0:
71327133
version "4.0.4"
@@ -8369,9 +8370,9 @@ ejs@^3.0.1:
83698370
jake "^10.6.1"
83708371

83718372
electron-to-chromium@^1.3.591:
8372-
version "1.3.599"
8373-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.599.tgz#3fbb004733f3c0dcf59934c8644ddf800b94443a"
8374-
integrity sha512-u6VGpFsIzSCNrWJb1I72SUypz3EGoBaiEgygoMkd0IOcGR3WF3je5VTx9OIRI9Qd8UOMHinLImyJFkYHTq6nsg==
8373+
version "1.3.600"
8374+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.600.tgz#eb6aa7233ca1fbf0fa9b5943c0f1061b54a433bf"
8375+
integrity sha512-QmdzrDk4eOoqkhld+XflF6znZHMFN120EfLdXgFP2TzvQuD6EABwKIjOIopx5hvVOIb1ELUPkEgs/rXo0iiXbw==
83758376

83768377
elegant-spinner@^1.0.1:
83778378
version "1.0.1"
@@ -9130,6 +9131,11 @@ exit-hook@^1.0.0:
91309131
resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8"
91319132
integrity sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=
91329133

9134+
exit-on-epipe@~1.0.1:
9135+
version "1.0.1"
9136+
resolved "https://registry.yarnpkg.com/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz#0bdd92e87d5285d267daa8171d0eb06159689692"
9137+
integrity sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==
9138+
91339139
exit@^0.1.2:
91349140
version "0.1.2"
91359141
resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c"
@@ -12484,7 +12490,7 @@ jju@^1.1.0:
1248412490
resolved "https://registry.yarnpkg.com/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a"
1248512491
integrity sha1-o6vicYryQaKykE+EpiWXDzia4yo=
1248612492

12487-
joi@^17.1.1:
12493+
joi@^17.1.1, joi@^17.2.1:
1248812494
version "17.3.0"
1248912495
resolved "https://registry.yarnpkg.com/joi/-/joi-17.3.0.tgz#f1be4a6ce29bc1716665819ac361dfa139fff5d2"
1249012496
integrity sha512-Qh5gdU6niuYbUIUV5ejbsMiiFmBdw8Kcp8Buj2JntszCkCfxJ9Cz76OtHxOZMPXrt5810iDIXs+n1nNVoquHgg==
@@ -16532,6 +16538,11 @@ [email protected], pretty@^2.0.0:
1653216538
extend-shallow "^2.0.1"
1653316539
js-beautify "^1.6.12"
1653416540

16541+
printj@~1.1.0:
16542+
version "1.1.2"
16543+
resolved "https://registry.yarnpkg.com/printj/-/printj-1.1.2.tgz#d90deb2975a8b9f600fb3a1c94e3f4c53c78a222"
16544+
integrity sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==
16545+
1653516546
prismjs@^1.13.0, prismjs@^1.21.0:
1653616547
version "1.22.0"
1653716548
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.22.0.tgz#73c3400afc58a823dd7eed023f8e1ce9fd8977fa"
@@ -21529,10 +21540,10 @@ zepto@^1.2.0:
2152921540
integrity sha1-4Se9nmb9hGvl6rSME5SIL3wOT5g=
2153021541

2153121542
zip-stream@^4.0.0:
21532-
version "4.0.2"
21533-
resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-4.0.2.tgz#3a20f1bd7729c2b59fd4efa04df5eb7a5a217d2e"
21534-
integrity sha512-TGxB2g+1ur6MHkvM644DuZr8Uzyz0k0OYWtS3YlpfWBEmK4woaC2t3+pozEL3dBfIPmpgmClR5B2QRcMgGt22g==
21543+
version "4.0.4"
21544+
resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-4.0.4.tgz#3a8f100b73afaa7d1ae9338d910b321dec77ff3a"
21545+
integrity sha512-a65wQ3h5gcQ/nQGWV1mSZCEzCML6EK/vyVPcrPNynySP1j3VBbQKh3nhC8CbORb+jfl2vXvh56Ul5odP1bAHqw==
2153521546
dependencies:
2153621547
archiver-utils "^2.1.0"
21537-
compress-commons "^4.0.0"
21548+
compress-commons "^4.0.2"
2153821549
readable-stream "^3.6.0"

0 commit comments

Comments
 (0)