Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/build/src/error/monitor/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ const getGroupingHash = function(group, error, type) {
}

const getMetadata = function({ location, plugin }, childEnv, groupingHash) {
const pluginMetadata = getPluginMetadata(plugin)
const pluginMetadata = getPluginMetadata({ location, plugin })
const envMetadata = getEnvMetadata(childEnv)
const locationMetadata = getLocationMetadata(location, envMetadata)
return { location: locationMetadata, ...pluginMetadata, env: envMetadata, other: { groupingHash } }
}

const getPluginMetadata = function(plugin) {
const getPluginMetadata = function({ location, plugin }) {
if (plugin === undefined) {
return {}
}

const { pluginPackageJson, ...pluginA } = plugin
const homepage = getHomepage(pluginPackageJson)
const homepage = getHomepage(pluginPackageJson, location)
return { plugin: { ...pluginA, homepage }, pluginPackageJson }
}

Expand Down
8 changes: 6 additions & 2 deletions packages/build/src/error/parse/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ const getVersion = function({ version }) {
return version
}

const getHomepage = function(pluginPackageJson = {}) {
return getRepository(pluginPackageJson) || getNpmLink(pluginPackageJson) || getIssuesLink(pluginPackageJson)
const getHomepage = function(pluginPackageJson = {}, { loadedFrom }) {
return (
getRepository(pluginPackageJson) ||
getNpmLink(pluginPackageJson, { loadedFrom }) ||
getIssuesLink(pluginPackageJson)
)
}

const getRepository = function({ repository: { url } = {} }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: test
inputs: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[[plugins]]
package = "./plugin.js"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "test-plugin",
"description": "test",
"version": "1.0.0",
"private": true,
"author": "Netlify",
"license": "MIT",
"bugs": {
"url": "https://test.com"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
onPreBuild() {
throw new Error('test')
},
}
85 changes: 85 additions & 0 deletions packages/build/tests/error/snapshots/tests.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,91 @@ Generated by [AVA](https://ava.li).
}␊
}`

## Report plugin homepage without a repository

> Snapshot 1

`␊
┌─────────────────────────────┐␊
│ Netlify Build │␊
└─────────────────────────────┘␊
> Version␊
@netlify/build 1.0.0␊
> Flags␊
debug: true␊
repositoryRoot: /file/path␊
testOpts:␊
errorMonitor: true␊
> Current directory␊
/file/path␊
> Config file␊
/file/path␊
> Resolved config␊
plugins:␊
- inputs: {}␊
origin: config␊
package: /file/path␊
> Context␊
production␊
> Loading plugins␊
- /file/path from netlify.toml␊
┌────────────────────────────────────────┐␊
│ 1. onPreBuild command from /file/path │␊
└────────────────────────────────────────┘␊
┌─────────────────────────────────────┐␊
│ Plugin "/file/path" internal error │␊
└─────────────────────────────────────┘␊
Error message␊
Error: test␊
Plugin details␊
Package: /file/path␊
Version: 1.0.0␊
Report issues: https://test.com␊
Error location␊
In "onPreBuild" event in "/file/path" from netlify.toml␊
STACK TRACE␊
Resolved config␊
plugins:␊
- inputs: {}␊
origin: config␊
package: /file/path␊
Error monitoring payload:␊
{␊
"errorClass": "pluginInternal",␊
"errorMessage": "test",␊
"context": "Plugin /"/file/path" internal error",␊
"groupingHash": "Plugin /"/file/path" internal error/ntest",␊
"severity": "info",␊
"unhandled": false,␊
"location": {␊
"event": "onPreBuild",␊
"package": "/file/path",␊
"loadedFrom": "local",␊
"origin": "config"␊
},␊
"package": "/file/path",␊
"pluginPackageJson": true,␊
"homepage": "https://test.com",␊
"other": {␊
"groupingHash": "Plugin /"/file/path" internal error/ntest"␊
}␊
}`

## Report plugin input error

> Snapshot 1
Expand Down
Binary file modified packages/build/tests/error/snapshots/tests.js.snap
Binary file not shown.
4 changes: 4 additions & 0 deletions packages/build/tests/error/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ test('Report plugin homepage', async t => {
await runFixture(t, 'plugin_homepage', { flags })
})

test('Report plugin homepage without a repository', async t => {
await runFixture(t, 'plugin_homepage_no_repo', { flags })
})

test('Report plugin origin', async t => {
const defaultConfig = JSON.stringify({ plugins: [{ package: './plugin.js' }] })
await runFixture(t, 'plugin_origin', { flags: { ...flags, defaultConfig } })
Expand Down