@player-tools/cli 0.9.1-next.0 → 0.9.1-next.2
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.
|
@@ -44,11 +44,11 @@ class Validate extends base_command_1.BaseCommand {
|
|
|
44
44
|
files: Array.isArray(files) ? files : [files],
|
|
45
45
|
exp,
|
|
46
46
|
severity: flags.severity,
|
|
47
|
-
loglevel: flags.loglevel
|
|
47
|
+
loglevel: flags.loglevel,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
async run() {
|
|
51
|
-
const { files: inputFiles, exp, severity, loglevel } = await this.getOptions();
|
|
51
|
+
const { files: inputFiles, exp, severity, loglevel, } = await this.getOptions();
|
|
52
52
|
const expandedFilesList = (0, fs_2.convertToFileGlob)(inputFiles, "**/*.json");
|
|
53
53
|
this.debug("Searching for files using: %o", expandedFilesList);
|
|
54
54
|
const files = await (0, globby_1.default)(expandedFilesList, {
|
|
@@ -71,7 +71,7 @@ class Validate extends base_command_1.BaseCommand {
|
|
|
71
71
|
return validations;
|
|
72
72
|
},
|
|
73
73
|
})),
|
|
74
|
-
loglevel: (0, log_levels_1.stringToLogLevel)(loglevel)
|
|
74
|
+
loglevel: (0, log_levels_1.stringToLogLevel)(loglevel),
|
|
75
75
|
});
|
|
76
76
|
const taskResults = await taskRunner.run();
|
|
77
77
|
if (severity !== "error") {
|
|
@@ -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,16 +85,46 @@ 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 = {
|
|
90
115
|
errors: 0,
|
|
91
116
|
warnings: 0,
|
|
92
117
|
info: 0,
|
|
93
|
-
trace: 0
|
|
118
|
+
trace: 0,
|
|
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
|
})
|
|
@@ -126,20 +158,10 @@ function formatDiagnosticResults(filePath, results, loglevel) {
|
|
|
126
158
|
];
|
|
127
159
|
}
|
|
128
160
|
else if (count.info > 0 && loglevel >= vscode_languageserver_types_1.DiagnosticSeverity.Information) {
|
|
129
|
-
lines = [
|
|
130
|
-
"",
|
|
131
|
-
`${chalk_1.default.blue(log_symbols_1.default.info)} ${filePath}`,
|
|
132
|
-
...lines,
|
|
133
|
-
"",
|
|
134
|
-
];
|
|
161
|
+
lines = ["", `${chalk_1.default.blue(log_symbols_1.default.info)} ${filePath}`, ...lines, ""];
|
|
135
162
|
}
|
|
136
163
|
else if (count.trace > 0 && loglevel >= vscode_languageserver_types_1.DiagnosticSeverity.Hint) {
|
|
137
|
-
lines = [
|
|
138
|
-
"",
|
|
139
|
-
`${chalk_1.default.gray(log_symbols_1.default.info)} ${filePath}`,
|
|
140
|
-
...lines,
|
|
141
|
-
"",
|
|
142
|
-
];
|
|
164
|
+
lines = ["", `${chalk_1.default.gray(log_symbols_1.default.info)} ${filePath}`, ...lines, ""];
|
|
143
165
|
}
|
|
144
166
|
else {
|
|
145
167
|
lines = [`${chalk_1.default.green(log_symbols_1.default.success)} ${filePath}`, ...lines];
|
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.9.1-next.
|
|
8
|
+
"version": "0.9.1-next.2",
|
|
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.9.1-next.
|
|
25
|
-
"@player-tools/json-language-service": "0.9.1-next.
|
|
26
|
-
"@player-tools/xlr": "0.9.1-next.
|
|
27
|
-
"@player-tools/xlr-converters": "0.9.1-next.
|
|
28
|
-
"@player-tools/xlr-sdk": "0.9.1-next.
|
|
29
|
-
"@player-tools/xlr-utils": "0.9.1-next.
|
|
24
|
+
"@player-tools/dsl": "0.9.1-next.2",
|
|
25
|
+
"@player-tools/json-language-service": "0.9.1-next.2",
|
|
26
|
+
"@player-tools/xlr": "0.9.1-next.2",
|
|
27
|
+
"@player-tools/xlr-converters": "0.9.1-next.2",
|
|
28
|
+
"@player-tools/xlr-sdk": "0.9.1-next.2",
|
|
29
|
+
"@player-tools/xlr-utils": "0.9.1-next.2",
|
|
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",
|