@atlaspack/utils 3.2.9-dev-swc44-53cdb819f.0 → 3.3.0
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/CHANGELOG.md +16 -0
- package/dist/prettyDiagnostic.js +6 -2
- package/lib/prettyDiagnostic.js +6 -2
- package/lib/types/prettyDiagnostic.d.ts +1 -0
- package/package.json +14 -15
- package/src/prettyDiagnostic.ts +14 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/LICENSE +0 -201
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaspack/utils
|
|
2
2
|
|
|
3
|
+
## 3.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#955](https://github.com/atlassian-labs/atlaspack/pull/955) [`47aa84e`](https://github.com/atlassian-labs/atlaspack/commit/47aa84e44c61066072a5bf3d57678565b9d2c5a3) Thanks [@marcins](https://github.com/marcins)! - Implement a prettyDiagnosticSync function for use in non-async contexts
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`564fb4f`](https://github.com/atlassian-labs/atlaspack/commit/564fb4fecc2a20bdeb951863a8fac29b618d91b7), [`9df722c`](https://github.com/atlassian-labs/atlaspack/commit/9df722c38b225054883693ba9731344f701767a7), [`c31090c`](https://github.com/atlassian-labs/atlaspack/commit/c31090c9025f35d3fa8561b42dca170853a32e6f), [`565bab3`](https://github.com/atlassian-labs/atlaspack/commit/565bab3771cc334659d873cabff4cdfac0860cc7), [`34b01ec`](https://github.com/atlassian-labs/atlaspack/commit/34b01ec03e2264bd617be000465821e1ed11eae5), [`6e5fec1`](https://github.com/atlassian-labs/atlaspack/commit/6e5fec1406c53257be7e7fbe06c028beda70fcf1), [`e4e5522`](https://github.com/atlassian-labs/atlaspack/commit/e4e55222422d8c73653d3ea09f1a0d13946345b9)]:
|
|
12
|
+
- @atlaspack/rust@3.18.0
|
|
13
|
+
- @atlaspack/feature-flags@2.27.6
|
|
14
|
+
- @atlaspack/logger@2.14.40
|
|
15
|
+
- @atlaspack/source-map@3.2.3
|
|
16
|
+
- @atlaspack/types-internal@2.22.5
|
|
17
|
+
- @atlaspack/codeframe@2.13.30
|
|
18
|
+
|
|
3
19
|
## 3.2.8
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/prettyDiagnostic.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.prettyDiagnosticSync = prettyDiagnosticSync;
|
|
6
7
|
exports.default = prettyDiagnostic;
|
|
7
8
|
const codeframe_1 = __importDefault(require("@atlaspack/codeframe"));
|
|
8
9
|
const logger_1 = __importDefault(require("@atlaspack/logger"));
|
|
@@ -12,7 +13,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
12
13
|
const terminal_link_1 = __importDefault(require("terminal-link"));
|
|
13
14
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
14
15
|
const snarkdown_1 = __importDefault(require("snarkdown"));
|
|
15
|
-
|
|
16
|
+
function prettyDiagnosticSync(diagnostic, options, terminalWidth, format = 'ansi') {
|
|
16
17
|
let { origin, message, stack, codeFrames, hints, skipFormatting, documentationURL, } = diagnostic;
|
|
17
18
|
const md = format === 'ansi' ? markdown_ansi_1.default : snarkdown_1.default;
|
|
18
19
|
const terminalLink = format === 'ansi'
|
|
@@ -45,7 +46,7 @@ async function prettyDiagnostic(diagnostic, options, terminalWidth, format = 'an
|
|
|
45
46
|
let code = codeFrame.code;
|
|
46
47
|
if (code == null && options && filePath != null) {
|
|
47
48
|
try {
|
|
48
|
-
code =
|
|
49
|
+
code = options.inputFS.readFileSync(filePath, 'utf8');
|
|
49
50
|
}
|
|
50
51
|
catch (e) {
|
|
51
52
|
// In strange cases this can fail and hide the underlying error.
|
|
@@ -102,3 +103,6 @@ async function prettyDiagnostic(diagnostic, options, terminalWidth, format = 'an
|
|
|
102
103
|
}
|
|
103
104
|
return result;
|
|
104
105
|
}
|
|
106
|
+
function prettyDiagnostic(diagnostic, options, terminalWidth, format = 'ansi') {
|
|
107
|
+
return Promise.resolve(prettyDiagnosticSync(diagnostic, options, terminalWidth, format));
|
|
108
|
+
}
|
package/lib/prettyDiagnostic.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = prettyDiagnostic;
|
|
7
|
+
exports.prettyDiagnosticSync = prettyDiagnosticSync;
|
|
7
8
|
function _codeframe() {
|
|
8
9
|
const data = _interopRequireDefault(require("@atlaspack/codeframe"));
|
|
9
10
|
_codeframe = function () {
|
|
@@ -58,7 +59,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
58
59
|
|
|
59
60
|
/* eslint-enable import/no-extraneous-dependencies */
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
function prettyDiagnosticSync(diagnostic, options, terminalWidth, format = 'ansi') {
|
|
62
63
|
let {
|
|
63
64
|
origin,
|
|
64
65
|
message,
|
|
@@ -95,7 +96,7 @@ async function prettyDiagnostic(diagnostic, options, terminalWidth, format = 'an
|
|
|
95
96
|
let code = codeFrame.code;
|
|
96
97
|
if (code == null && options && filePath != null) {
|
|
97
98
|
try {
|
|
98
|
-
code =
|
|
99
|
+
code = options.inputFS.readFileSync(filePath, 'utf8');
|
|
99
100
|
} catch (e) {
|
|
100
101
|
// In strange cases this can fail and hide the underlying error.
|
|
101
102
|
_logger().default.warn({
|
|
@@ -147,4 +148,7 @@ async function prettyDiagnostic(diagnostic, options, terminalWidth, format = 'an
|
|
|
147
148
|
});
|
|
148
149
|
}
|
|
149
150
|
return result;
|
|
151
|
+
}
|
|
152
|
+
function prettyDiagnostic(diagnostic, options, terminalWidth, format = 'ansi') {
|
|
153
|
+
return Promise.resolve(prettyDiagnosticSync(diagnostic, options, terminalWidth, format));
|
|
150
154
|
}
|
|
@@ -14,4 +14,5 @@ export type AnsiDiagnosticResult = {
|
|
|
14
14
|
hints: Array<string>;
|
|
15
15
|
documentation: string;
|
|
16
16
|
};
|
|
17
|
+
export declare function prettyDiagnosticSync(diagnostic: Diagnostic, options?: PluginOptions, terminalWidth?: number, format?: 'ansi' | 'html'): AnsiDiagnosticResult;
|
|
17
18
|
export default function prettyDiagnostic(diagnostic: Diagnostic, options?: PluginOptions, terminalWidth?: number, format?: 'ansi' | 'html'): Promise<AnsiDiagnosticResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,19 +31,20 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaspack/codeframe": "2.13.30
|
|
35
|
-
"@atlaspack/diagnostic": "2.14.
|
|
36
|
-
"@atlaspack/feature-flags": "2.27.6
|
|
37
|
-
"@atlaspack/logger": "2.14.40
|
|
38
|
-
"@atlaspack/markdown-ansi": "2.14.
|
|
39
|
-
"@atlaspack/
|
|
40
|
-
"@atlaspack/
|
|
41
|
-
"@atlaspack/
|
|
42
|
-
"@iarna/toml": "^2.2.0",
|
|
34
|
+
"@atlaspack/codeframe": "2.13.30",
|
|
35
|
+
"@atlaspack/diagnostic": "2.14.4",
|
|
36
|
+
"@atlaspack/feature-flags": "2.27.6",
|
|
37
|
+
"@atlaspack/logger": "2.14.40",
|
|
38
|
+
"@atlaspack/markdown-ansi": "2.14.4",
|
|
39
|
+
"@atlaspack/types-internal": "2.22.5",
|
|
40
|
+
"@atlaspack/rust": "3.18.0",
|
|
41
|
+
"@atlaspack/source-map": "3.2.3",
|
|
43
42
|
"@types/micromatch": "^4.0.9",
|
|
44
43
|
"@types/node-forge": "^1.3.13",
|
|
45
|
-
"ansi-html-community": "0.0.8",
|
|
46
44
|
"chalk": "^4.1.0",
|
|
45
|
+
"nullthrows": "^1.1.1",
|
|
46
|
+
"@iarna/toml": "^2.2.0",
|
|
47
|
+
"ansi-html-community": "0.0.8",
|
|
47
48
|
"clone": "^2.1.1",
|
|
48
49
|
"fast-glob": "^3.2.12",
|
|
49
50
|
"fastest-levenshtein": "^1.0.16",
|
|
@@ -53,14 +54,13 @@
|
|
|
53
54
|
"lru-cache": "^6.0.0",
|
|
54
55
|
"micromatch": "^4.0.4",
|
|
55
56
|
"node-forge": "^1.2.1",
|
|
56
|
-
"nullthrows": "^1.1.1",
|
|
57
57
|
"open": "^7.0.3",
|
|
58
58
|
"snarkdown": "^2.0.0",
|
|
59
59
|
"strip-ansi": "^6.0.0",
|
|
60
60
|
"terminal-link": "^2.1.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@atlaspack/babel-register": "2.14.
|
|
63
|
+
"@atlaspack/babel-register": "2.14.4",
|
|
64
64
|
"@types/is-glob": "^4.0.1",
|
|
65
65
|
"benny": "^3.7.1",
|
|
66
66
|
"random-int": "^1.0.0"
|
|
@@ -74,6 +74,5 @@
|
|
|
74
74
|
"type": "commonjs",
|
|
75
75
|
"scripts": {
|
|
76
76
|
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
77
|
-
}
|
|
78
|
-
"gitHead": "53cdb819f1739c63fb7dc9769cdd64352c097f9a"
|
|
77
|
+
}
|
|
79
78
|
}
|
package/src/prettyDiagnostic.ts
CHANGED
|
@@ -28,12 +28,12 @@ export type AnsiDiagnosticResult = {
|
|
|
28
28
|
documentation: string;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export
|
|
31
|
+
export function prettyDiagnosticSync(
|
|
32
32
|
diagnostic: Diagnostic,
|
|
33
33
|
options?: PluginOptions,
|
|
34
34
|
terminalWidth?: number,
|
|
35
35
|
format: 'ansi' | 'html' = 'ansi',
|
|
36
|
-
):
|
|
36
|
+
): AnsiDiagnosticResult {
|
|
37
37
|
let {
|
|
38
38
|
origin,
|
|
39
39
|
message,
|
|
@@ -88,7 +88,7 @@ export default async function prettyDiagnostic(
|
|
|
88
88
|
let code = codeFrame.code;
|
|
89
89
|
if (code == null && options && filePath != null) {
|
|
90
90
|
try {
|
|
91
|
-
code =
|
|
91
|
+
code = options.inputFS.readFileSync(filePath, 'utf8');
|
|
92
92
|
} catch (e) {
|
|
93
93
|
// In strange cases this can fail and hide the underlying error.
|
|
94
94
|
logger.warn({
|
|
@@ -150,3 +150,14 @@ export default async function prettyDiagnostic(
|
|
|
150
150
|
|
|
151
151
|
return result;
|
|
152
152
|
}
|
|
153
|
+
|
|
154
|
+
export default function prettyDiagnostic(
|
|
155
|
+
diagnostic: Diagnostic,
|
|
156
|
+
options?: PluginOptions,
|
|
157
|
+
terminalWidth?: number,
|
|
158
|
+
format: 'ansi' | 'html' = 'ansi',
|
|
159
|
+
): Promise<AnsiDiagnosticResult> {
|
|
160
|
+
return Promise.resolve(
|
|
161
|
+
prettyDiagnosticSync(diagnostic, options, terminalWidth, format),
|
|
162
|
+
);
|
|
163
|
+
}
|