@parcel/utils 2.10.1 → 2.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +63 -5
- package/lib/index.js.map +1 -1
- package/package.json +10 -8
- package/src/prettyDiagnostic.js +28 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/utils",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.3",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@parcel/codeframe": "2.10.
|
|
37
|
-
"@parcel/diagnostic": "2.10.
|
|
38
|
-
"@parcel/logger": "2.10.
|
|
39
|
-
"@parcel/markdown-ansi": "2.10.
|
|
40
|
-
"@parcel/rust": "2.10.
|
|
36
|
+
"@parcel/codeframe": "2.10.3",
|
|
37
|
+
"@parcel/diagnostic": "2.10.3",
|
|
38
|
+
"@parcel/logger": "2.10.3",
|
|
39
|
+
"@parcel/markdown-ansi": "2.10.3",
|
|
40
|
+
"@parcel/rust": "2.10.3",
|
|
41
41
|
"@parcel/source-map": "^2.1.1",
|
|
42
42
|
"chalk": "^4.1.0",
|
|
43
43
|
"nullthrows": "^1.1.1"
|
|
@@ -57,13 +57,15 @@
|
|
|
57
57
|
"nullthrows": "^1.1.1",
|
|
58
58
|
"open": "^7.0.3",
|
|
59
59
|
"random-int": "^1.0.0",
|
|
60
|
+
"snarkdown": "^2.0.0",
|
|
60
61
|
"strip-ansi": "^6.0.0",
|
|
61
62
|
"terminal-link": "^2.1.1"
|
|
62
63
|
},
|
|
63
64
|
"browser": {
|
|
64
65
|
"./src/generateCertificate.js": false,
|
|
65
66
|
"./src/http-server.js": false,
|
|
66
|
-
"./src/openInBrowser.js": false
|
|
67
|
+
"./src/openInBrowser.js": false,
|
|
68
|
+
"@parcel/markdown-ansi": false
|
|
67
69
|
},
|
|
68
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "65d42a955db665a04817fa9be55df16f588593d4"
|
|
69
71
|
}
|
package/src/prettyDiagnostic.js
CHANGED
|
@@ -3,11 +3,16 @@ import type {Diagnostic} from '@parcel/diagnostic';
|
|
|
3
3
|
import type {PluginOptions} from '@parcel/types';
|
|
4
4
|
|
|
5
5
|
import formatCodeFrame from '@parcel/codeframe';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import _mdAnsi from '@parcel/markdown-ansi';
|
|
7
|
+
import _chalk from 'chalk';
|
|
8
8
|
import path from 'path';
|
|
9
9
|
// $FlowFixMe
|
|
10
|
-
import
|
|
10
|
+
import _terminalLink from 'terminal-link';
|
|
11
|
+
|
|
12
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
13
|
+
// $FlowFixMe
|
|
14
|
+
import snarkdown from 'snarkdown';
|
|
15
|
+
/* eslint-enable import/no-extraneous-dependencies */
|
|
11
16
|
|
|
12
17
|
export type FormattedCodeFrame = {|
|
|
13
18
|
location: string,
|
|
@@ -29,6 +34,7 @@ export default async function prettyDiagnostic(
|
|
|
29
34
|
diagnostic: Diagnostic,
|
|
30
35
|
options?: PluginOptions,
|
|
31
36
|
terminalWidth?: number,
|
|
37
|
+
format: 'ansi' | 'html' = 'ansi',
|
|
32
38
|
): Promise<AnsiDiagnosticResult> {
|
|
33
39
|
let {
|
|
34
40
|
origin,
|
|
@@ -40,10 +46,26 @@ export default async function prettyDiagnostic(
|
|
|
40
46
|
documentationURL,
|
|
41
47
|
} = diagnostic;
|
|
42
48
|
|
|
49
|
+
const md = format === 'ansi' ? _mdAnsi : snarkdown;
|
|
50
|
+
const terminalLink =
|
|
51
|
+
format === 'ansi'
|
|
52
|
+
? _terminalLink
|
|
53
|
+
: // eslint-disable-next-line no-unused-vars
|
|
54
|
+
(text, url, _) => `<a href="${url}">${text}</a>`;
|
|
55
|
+
const chalk =
|
|
56
|
+
format === 'ansi'
|
|
57
|
+
? _chalk
|
|
58
|
+
: {
|
|
59
|
+
gray: {
|
|
60
|
+
underline: v =>
|
|
61
|
+
`<span style="color: grey; text-decoration: underline;">${v}</span>`,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
43
65
|
let result = {
|
|
44
66
|
message:
|
|
45
|
-
|
|
46
|
-
(skipFormatting ? message :
|
|
67
|
+
md(`**${origin ?? 'unknown'}**: `) +
|
|
68
|
+
(skipFormatting ? message : md(message)),
|
|
47
69
|
stack: '',
|
|
48
70
|
codeframe: '',
|
|
49
71
|
frames: [],
|
|
@@ -104,7 +126,7 @@ export default async function prettyDiagnostic(
|
|
|
104
126
|
|
|
105
127
|
if (Array.isArray(hints) && hints.length) {
|
|
106
128
|
result.hints = hints.map(h => {
|
|
107
|
-
return
|
|
129
|
+
return md(h);
|
|
108
130
|
});
|
|
109
131
|
}
|
|
110
132
|
|