@groma/scanner-go 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/darwin-arm64/worker +0 -0
- package/dist/linux-arm64/worker +0 -0
- package/dist/linux-x64/worker +0 -0
- package/dist/win32-arm64/worker.exe +0 -0
- package/dist/win32-x64/worker.exe +0 -0
- package/package.json +2 -2
- package/src/index.js +15 -15
package/dist/darwin-arm64/worker
CHANGED
|
Binary file
|
package/dist/linux-arm64/worker
CHANGED
|
Binary file
|
package/dist/linux-x64/worker
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@groma/scanner-go",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Go project evidence through Go language tooling.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"repository": {
|
|
51
51
|
"type": "git",
|
|
52
|
-
"url": "https://github.com/MrLesk/
|
|
52
|
+
"url": "https://github.com/MrLesk/groma.md.git"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
package/src/index.js
CHANGED
|
@@ -124,13 +124,13 @@ function compare(...values) {
|
|
|
124
124
|
}
|
|
125
125
|
function uniqueBy(values, key, label) {
|
|
126
126
|
const seen = new Set;
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
const keyed = values.map((value) => ({ id: key(value), value }));
|
|
128
|
+
for (const { id } of keyed) {
|
|
129
129
|
if (seen.has(id))
|
|
130
130
|
throw new Error(`duplicate ${label}: ${id}`);
|
|
131
131
|
seen.add(id);
|
|
132
132
|
}
|
|
133
|
-
return
|
|
133
|
+
return keyed.sort((left, right) => left.id.localeCompare(right.id)).map((entry) => entry.value);
|
|
134
134
|
}
|
|
135
135
|
function createScanObservation(input) {
|
|
136
136
|
const roots = validateRoots(input.roots);
|
|
@@ -141,9 +141,7 @@ function createScanObservation(input) {
|
|
|
141
141
|
symbols: [...new Map(file.symbols.map((symbol) => [
|
|
142
142
|
compare(symbol.id, symbol.kind),
|
|
143
143
|
symbol
|
|
144
|
-
]))
|
|
145
|
-
return compare(left.id, left.kind).localeCompare(compare(right.id, right.kind));
|
|
146
|
-
})
|
|
144
|
+
]))].sort(([left], [right]) => left.localeCompare(right)).map(([, symbol]) => symbol)
|
|
147
145
|
})), (file) => file.file, "file path");
|
|
148
146
|
const filePaths = new Set(files.map((file) => file.file));
|
|
149
147
|
for (const file of files) {
|
|
@@ -154,8 +152,6 @@ function createScanObservation(input) {
|
|
|
154
152
|
throw new Error(`file references unknown root: ${root}`);
|
|
155
153
|
}
|
|
156
154
|
}
|
|
157
|
-
for (const diagnostic of input.diagnostics)
|
|
158
|
-
diagnosticLocation(diagnostic);
|
|
159
155
|
return {
|
|
160
156
|
schemaVersion: 1,
|
|
161
157
|
scanner: input.scanner,
|
|
@@ -165,14 +161,14 @@ function createScanObservation(input) {
|
|
|
165
161
|
...entryPoints(input.entryPoints, filePaths),
|
|
166
162
|
...operationEvidence(input, filePaths),
|
|
167
163
|
...httpEvidence(input.httpEndpoints, input.httpRequests, input.operations && new Set(input.operations.map((operation) => operation.id))),
|
|
168
|
-
diagnostics:
|
|
169
|
-
diagnosticKey(diagnostic),
|
|
170
|
-
diagnostic
|
|
171
|
-
])).values()].sort((left, right) => {
|
|
172
|
-
return diagnosticKey(left).localeCompare(diagnosticKey(right));
|
|
173
|
-
})
|
|
164
|
+
diagnostics: normalizeScanDiagnostics(input.diagnostics)
|
|
174
165
|
};
|
|
175
166
|
}
|
|
167
|
+
function normalizeScanDiagnostics(diagnostics) {
|
|
168
|
+
for (const diagnostic of diagnostics)
|
|
169
|
+
diagnosticLocation(diagnostic);
|
|
170
|
+
return [...new Map(diagnostics.map((diagnostic) => [diagnosticKey(diagnostic), diagnostic]))].sort(([left], [right]) => left.localeCompare(right)).map(([, diagnostic]) => diagnostic);
|
|
171
|
+
}
|
|
176
172
|
function entryPoints(input, paths) {
|
|
177
173
|
if (input === undefined)
|
|
178
174
|
return {};
|
|
@@ -371,10 +367,14 @@ function operationTokens(operation) {
|
|
|
371
367
|
const endLine = Number(operation.endLine);
|
|
372
368
|
if (endLine < startLine)
|
|
373
369
|
throw new Error("operation.endLine must be at or after startLine");
|
|
370
|
+
const tokens = array(operation.tokens, "operation.tokens");
|
|
371
|
+
tokens.forEach((token) => {
|
|
372
|
+
string(token, "operation.token");
|
|
373
|
+
});
|
|
374
374
|
return {
|
|
375
375
|
startLine,
|
|
376
376
|
endLine,
|
|
377
|
-
tokens
|
|
377
|
+
tokens
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
380
|
function validateOperationTokens(operation) {
|