Skip to content

Commit a60dc4e

Browse files
author
Guillaume Chau
committed
feat(ui): PluginApi validation: better errors
1 parent a4f6e1d commit a60dc4e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/@vue/cli-ui/src/graphql-api/api/PluginApi.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class PluginApi {
1313
this.tasks = []
1414
this.clientAddons = []
1515
this.actions = new Map()
16+
this.pluginId = null
1617
}
1718

1819
describeConfig (options) {
@@ -23,9 +24,9 @@ class PluginApi {
2324
logs.add({
2425
type: 'error',
2526
tag: 'PluginApi',
26-
message: 'describeConfig options are invalid\n' +
27-
e.message
27+
message: `(${this.pluginId || 'unknown plugin'}) 'describeConfig' options are invalid\n${e.message}`
2828
}, this.context)
29+
console.error(new Error(`Invalid options: ${e.message}`))
2930
}
3031
}
3132

@@ -37,9 +38,9 @@ class PluginApi {
3738
logs.add({
3839
type: 'error',
3940
tag: 'PluginApi',
40-
message: 'describeTask options are invalid\n' +
41-
e.message
41+
message: `(${this.pluginId || 'unknown plugin'}) 'describeTask' options are invalid\n${e.message}`
4242
}, this.context)
43+
console.error(new Error(`Invalid options: ${e.message}`))
4344
}
4445
}
4546

@@ -57,9 +58,9 @@ class PluginApi {
5758
logs.add({
5859
type: 'error',
5960
tag: 'PluginApi',
60-
message: 'addClientAddon options are invalid\n' +
61-
e.message
61+
message: `(${this.pluginId || 'unknown plugin'}) 'addClientAddon' options are invalid\n${e.message}`
6262
}, this.context)
63+
console.error(new Error(`Invalid options: ${e.message}`))
6364
}
6465
}
6566

packages/@vue/cli-ui/src/graphql-api/connectors/plugins.js

+2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ function resetPluginApi (context) {
8989
function runPluginApi (id, context, fileName = 'ui') {
9090
const module = loadModule(`${id}/${fileName}`, cwd.get(), true)
9191
if (module) {
92+
pluginApi.pluginId = id
9293
module(pluginApi)
94+
pluginApi.pluginId = null
9395
}
9496
}
9597

0 commit comments

Comments
 (0)