@player-tools/cli 0.9.1-next.1 → 0.10.0-next.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/dist/utils/diag-renderer.js +33 -1
- package/dist/utils/fs.d.ts +4 -0
- package/dist/utils/fs.js +12 -1
- package/package.json +8 -7
|
@@ -9,6 +9,7 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
|
9
9
|
const log_symbols_1 = tslib_1.__importDefault(require("log-symbols"));
|
|
10
10
|
const elegant_spinner_1 = tslib_1.__importDefault(require("elegant-spinner"));
|
|
11
11
|
const fs_1 = require("./fs");
|
|
12
|
+
const source_map_js_1 = tslib_1.__importDefault(require("source-map-js"));
|
|
12
13
|
/** Compare the ranges and return the one that starts of finishes first */
|
|
13
14
|
function rangeComparator(first, second) {
|
|
14
15
|
if (first.start.line < second.start.line) {
|
|
@@ -84,6 +85,30 @@ function formatDiagnostic(diag, longestLine, fName) {
|
|
|
84
85
|
`${fName}:${range.padEnd(longestLine)}`,
|
|
85
86
|
].join(" ");
|
|
86
87
|
}
|
|
88
|
+
function mapDiagnosticBackToSourceLine(diag, mapper) {
|
|
89
|
+
const { line, character } = diag.range.start;
|
|
90
|
+
if (mapper && line && character >= 1) {
|
|
91
|
+
const sourceNode = mapper.originalPositionFor({
|
|
92
|
+
line,
|
|
93
|
+
column: character,
|
|
94
|
+
});
|
|
95
|
+
if (sourceNode.source) {
|
|
96
|
+
return {
|
|
97
|
+
diagnostic: {
|
|
98
|
+
...diag,
|
|
99
|
+
range: {
|
|
100
|
+
...diag.range,
|
|
101
|
+
start: {
|
|
102
|
+
line: sourceNode.line,
|
|
103
|
+
character: sourceNode.column,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
sourceFile: sourceNode.source,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
87
112
|
/** Format the results for printing on the console */
|
|
88
113
|
function formatDiagnosticResults(filePath, results, loglevel) {
|
|
89
114
|
const count = {
|
|
@@ -94,6 +119,12 @@ function formatDiagnosticResults(filePath, results, loglevel) {
|
|
|
94
119
|
};
|
|
95
120
|
const linePrefix = " ";
|
|
96
121
|
const longestLine = Math.max(...results.map((r) => getLineRange(r.range).length));
|
|
122
|
+
//try and load map file
|
|
123
|
+
const mapFile = (0, fs_1.tryAndLoadSourceMap)(filePath);
|
|
124
|
+
let sourceMapper;
|
|
125
|
+
if (mapFile) {
|
|
126
|
+
sourceMapper = new source_map_js_1.default.SourceMapConsumer(JSON.parse(mapFile));
|
|
127
|
+
}
|
|
97
128
|
let lines = results
|
|
98
129
|
.map((diag) => {
|
|
99
130
|
if (diag.severity === vscode_languageserver_types_1.DiagnosticSeverity.Error) {
|
|
@@ -108,8 +139,9 @@ function formatDiagnosticResults(filePath, results, loglevel) {
|
|
|
108
139
|
else if (diag.severity === vscode_languageserver_types_1.DiagnosticSeverity.Hint) {
|
|
109
140
|
count.trace += 1;
|
|
110
141
|
}
|
|
142
|
+
const { diagnostic, sourceFile } = mapDiagnosticBackToSourceLine(diag, sourceMapper) ?? { diagnostic: diag, sourceFile: filePath };
|
|
111
143
|
if (diag.severity && loglevel >= diag.severity) {
|
|
112
|
-
return linePrefix + formatDiagnostic(
|
|
144
|
+
return (linePrefix + formatDiagnostic(diagnostic, longestLine + 1, sourceFile));
|
|
113
145
|
}
|
|
114
146
|
return "";
|
|
115
147
|
})
|
package/dist/utils/fs.d.ts
CHANGED
|
@@ -2,4 +2,8 @@
|
|
|
2
2
|
export declare const convertToFileGlob: (input: string[], glob: string) => string[];
|
|
3
3
|
/** Normalize a path for display */
|
|
4
4
|
export declare const normalizePath: (p: string) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Tries to load a source map file
|
|
7
|
+
*/
|
|
8
|
+
export declare const tryAndLoadSourceMap: (f: string) => string | undefined;
|
|
5
9
|
//# sourceMappingURL=fs.d.ts.map
|
package/dist/utils/fs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizePath = exports.convertToFileGlob = void 0;
|
|
3
|
+
exports.tryAndLoadSourceMap = exports.normalizePath = exports.convertToFileGlob = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
@@ -28,4 +28,15 @@ const normalizePath = (p) => {
|
|
|
28
28
|
return path_1.default.relative(process.cwd(), p);
|
|
29
29
|
};
|
|
30
30
|
exports.normalizePath = normalizePath;
|
|
31
|
+
/**
|
|
32
|
+
* Tries to load a source map file
|
|
33
|
+
*/
|
|
34
|
+
const tryAndLoadSourceMap = (f) => {
|
|
35
|
+
const mapFileName = f + ".map";
|
|
36
|
+
if (fs_1.default.existsSync(mapFileName)) {
|
|
37
|
+
return fs_1.default.readFileSync(mapFileName, "utf8");
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
};
|
|
41
|
+
exports.tryAndLoadSourceMap = tryAndLoadSourceMap;
|
|
31
42
|
//# sourceMappingURL=fs.js.map
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
7
7
|
"name": "@player-tools/cli",
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.10.0-next.0",
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"oclif": {
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"player": "bin/run"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@player-tools/dsl": "0.
|
|
25
|
-
"@player-tools/json-language-service": "0.
|
|
26
|
-
"@player-tools/xlr": "0.
|
|
27
|
-
"@player-tools/xlr-converters": "0.
|
|
28
|
-
"@player-tools/xlr-sdk": "0.
|
|
29
|
-
"@player-tools/xlr-utils": "0.
|
|
24
|
+
"@player-tools/dsl": "0.10.0-next.0",
|
|
25
|
+
"@player-tools/json-language-service": "0.10.0-next.0",
|
|
26
|
+
"@player-tools/xlr": "0.10.0-next.0",
|
|
27
|
+
"@player-tools/xlr-converters": "0.10.0-next.0",
|
|
28
|
+
"@player-tools/xlr-sdk": "0.10.0-next.0",
|
|
29
|
+
"@player-tools/xlr-utils": "0.10.0-next.0",
|
|
30
30
|
"@babel/plugin-transform-react-jsx-source": "^7.23.3",
|
|
31
31
|
"@babel/preset-env": "^7.23.3",
|
|
32
32
|
"@babel/preset-react": "^7.23.3",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"log-update": "^4.0.0",
|
|
48
48
|
"mkdirp": "^1.0.4",
|
|
49
49
|
"react": "^18.2.0",
|
|
50
|
+
"source-map-js": "^1.2.0",
|
|
50
51
|
"tapable-ts": "^0.2.4",
|
|
51
52
|
"tslib": "^2.6.2",
|
|
52
53
|
"typescript": "5.5.4",
|