@groma/scanner-csharp 0.2.0 → 0.2.1
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/index.js +15 -15
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -120,13 +120,13 @@ function compare(...values) {
|
|
|
120
120
|
}
|
|
121
121
|
function uniqueBy(values, key, label) {
|
|
122
122
|
const seen = new Set;
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
const keyed = values.map((value) => ({ id: key(value), value }));
|
|
124
|
+
for (const { id } of keyed) {
|
|
125
125
|
if (seen.has(id))
|
|
126
126
|
throw new Error(`duplicate ${label}: ${id}`);
|
|
127
127
|
seen.add(id);
|
|
128
128
|
}
|
|
129
|
-
return
|
|
129
|
+
return keyed.sort((left, right) => left.id.localeCompare(right.id)).map((entry) => entry.value);
|
|
130
130
|
}
|
|
131
131
|
function createScanObservation(input) {
|
|
132
132
|
const roots = validateRoots(input.roots);
|
|
@@ -137,9 +137,7 @@ function createScanObservation(input) {
|
|
|
137
137
|
symbols: [...new Map(file.symbols.map((symbol) => [
|
|
138
138
|
compare(symbol.id, symbol.kind),
|
|
139
139
|
symbol
|
|
140
|
-
]))
|
|
141
|
-
return compare(left.id, left.kind).localeCompare(compare(right.id, right.kind));
|
|
142
|
-
})
|
|
140
|
+
]))].sort(([left], [right]) => left.localeCompare(right)).map(([, symbol]) => symbol)
|
|
143
141
|
})), (file) => file.file, "file path");
|
|
144
142
|
const filePaths = new Set(files.map((file) => file.file));
|
|
145
143
|
for (const file of files) {
|
|
@@ -150,8 +148,6 @@ function createScanObservation(input) {
|
|
|
150
148
|
throw new Error(`file references unknown root: ${root}`);
|
|
151
149
|
}
|
|
152
150
|
}
|
|
153
|
-
for (const diagnostic of input.diagnostics)
|
|
154
|
-
diagnosticLocation(diagnostic);
|
|
155
151
|
return {
|
|
156
152
|
schemaVersion: 1,
|
|
157
153
|
scanner: input.scanner,
|
|
@@ -161,14 +157,14 @@ function createScanObservation(input) {
|
|
|
161
157
|
...entryPoints(input.entryPoints, filePaths),
|
|
162
158
|
...operationEvidence(input, filePaths),
|
|
163
159
|
...httpEvidence(input.httpEndpoints, input.httpRequests, input.operations && new Set(input.operations.map((operation) => operation.id))),
|
|
164
|
-
diagnostics:
|
|
165
|
-
diagnosticKey(diagnostic),
|
|
166
|
-
diagnostic
|
|
167
|
-
])).values()].sort((left, right) => {
|
|
168
|
-
return diagnosticKey(left).localeCompare(diagnosticKey(right));
|
|
169
|
-
})
|
|
160
|
+
diagnostics: normalizeScanDiagnostics(input.diagnostics)
|
|
170
161
|
};
|
|
171
162
|
}
|
|
163
|
+
function normalizeScanDiagnostics(diagnostics) {
|
|
164
|
+
for (const diagnostic of diagnostics)
|
|
165
|
+
diagnosticLocation(diagnostic);
|
|
166
|
+
return [...new Map(diagnostics.map((diagnostic) => [diagnosticKey(diagnostic), diagnostic]))].sort(([left], [right]) => left.localeCompare(right)).map(([, diagnostic]) => diagnostic);
|
|
167
|
+
}
|
|
172
168
|
function entryPoints(input, paths) {
|
|
173
169
|
if (input === undefined)
|
|
174
170
|
return {};
|
|
@@ -367,10 +363,14 @@ function operationTokens(operation) {
|
|
|
367
363
|
const endLine = Number(operation.endLine);
|
|
368
364
|
if (endLine < startLine)
|
|
369
365
|
throw new Error("operation.endLine must be at or after startLine");
|
|
366
|
+
const tokens = array(operation.tokens, "operation.tokens");
|
|
367
|
+
tokens.forEach((token) => {
|
|
368
|
+
string(token, "operation.token");
|
|
369
|
+
});
|
|
370
370
|
return {
|
|
371
371
|
startLine,
|
|
372
372
|
endLine,
|
|
373
|
-
tokens
|
|
373
|
+
tokens
|
|
374
374
|
};
|
|
375
375
|
}
|
|
376
376
|
function validateOperationTokens(operation) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@groma/scanner-csharp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/MrLesk/
|
|
9
|
+
"url": "https://github.com/MrLesk/groma.md.git"
|
|
10
10
|
},
|
|
11
11
|
"description": "C# project evidence through Roslyn.",
|
|
12
12
|
"publishConfig": {
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"x64"
|
|
29
29
|
],
|
|
30
30
|
"optionalDependencies": {
|
|
31
|
-
"@groma/scanner-csharp-darwin-arm64": "0.2.
|
|
32
|
-
"@groma/scanner-csharp-linux-arm64": "0.2.
|
|
33
|
-
"@groma/scanner-csharp-linux-x64": "0.2.
|
|
34
|
-
"@groma/scanner-csharp-win32-arm64": "0.2.
|
|
35
|
-
"@groma/scanner-csharp-win32-x64": "0.2.
|
|
31
|
+
"@groma/scanner-csharp-darwin-arm64": "0.2.1",
|
|
32
|
+
"@groma/scanner-csharp-linux-arm64": "0.2.1",
|
|
33
|
+
"@groma/scanner-csharp-linux-x64": "0.2.1",
|
|
34
|
+
"@groma/scanner-csharp-win32-arm64": "0.2.1",
|
|
35
|
+
"@groma/scanner-csharp-win32-x64": "0.2.1"
|
|
36
36
|
},
|
|
37
37
|
"groma": {
|
|
38
38
|
"scanner": {
|