refactor(reference): share graph index projections
This commit is contained in:
parent
a6d9e49ab4
commit
6ee87fbf2d
|
|
@ -2,6 +2,8 @@ import { compareUnicodeCodePoints } from "../domain/unicodeCodePointOrder.js";
|
|||
import { isSecretLikePath } from "../domain/referenceSourceClassification.js";
|
||||
import {
|
||||
createHistoricalSourceGraph,
|
||||
historicalSourceLanguages,
|
||||
historicalSourceManifests,
|
||||
historicalSourceParseFailureKey,
|
||||
type HistoricalSourceGraph,
|
||||
type HistoricalSourceGraphInput,
|
||||
|
|
@ -83,30 +85,6 @@ const buildProvenance = (
|
|||
caller: options.caller,
|
||||
});
|
||||
|
||||
const deriveLanguages = (
|
||||
entries: HistoricalSourceGraphInput["entries"],
|
||||
): string[] =>
|
||||
[
|
||||
...new Set(
|
||||
entries.flatMap((entry) =>
|
||||
entry.kind === "file" && entry.language !== null
|
||||
? [entry.language]
|
||||
: [],
|
||||
),
|
||||
),
|
||||
].sort(compareUnicodeCodePoints);
|
||||
|
||||
const deriveManifests = (
|
||||
entries: HistoricalSourceGraphInput["entries"],
|
||||
): string[] =>
|
||||
entries
|
||||
.flatMap((entry) =>
|
||||
entry.kind === "file" && entry.classifications.includes("manifest")
|
||||
? [entry.path]
|
||||
: [],
|
||||
)
|
||||
.sort(compareUnicodeCodePoints);
|
||||
|
||||
const deriveInventoryState = (
|
||||
input: Pick<
|
||||
HistoricalSourceGraphInput,
|
||||
|
|
@ -229,8 +207,8 @@ export const importReferenceSource = async (
|
|||
),
|
||||
parse_failures: uniqueFailures,
|
||||
exclusions: sortedExclusions,
|
||||
languages: deriveLanguages(sortedEntries),
|
||||
manifests: deriveManifests(sortedEntries),
|
||||
languages: historicalSourceLanguages(sortedEntries),
|
||||
manifests: historicalSourceManifests(sortedEntries),
|
||||
vcs,
|
||||
provenance: buildProvenance(options),
|
||||
limitations: sortedLimitations,
|
||||
|
|
|
|||
|
|
@ -255,7 +255,8 @@ const checkSortedUnique = (
|
|||
}
|
||||
};
|
||||
|
||||
const expectedLanguages = (
|
||||
/** Derive the canonical language index from inventoried source files. */
|
||||
export const historicalSourceLanguages = (
|
||||
entries: readonly z.infer<typeof sourceEntrySchema>[],
|
||||
): string[] =>
|
||||
[
|
||||
|
|
@ -268,7 +269,8 @@ const expectedLanguages = (
|
|||
),
|
||||
].sort(compareUnicodeCodePoints);
|
||||
|
||||
const expectedManifests = (
|
||||
/** Derive the canonical manifest path index from inventoried source files. */
|
||||
export const historicalSourceManifests = (
|
||||
entries: readonly z.infer<typeof sourceEntrySchema>[],
|
||||
): string[] =>
|
||||
entries
|
||||
|
|
@ -408,7 +410,7 @@ function checkGraphInvariants(
|
|||
|
||||
if (
|
||||
canonicalJson(graph.languages) !==
|
||||
canonicalJson(expectedLanguages(graph.entries))
|
||||
canonicalJson(historicalSourceLanguages(graph.entries))
|
||||
)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
|
|
@ -417,7 +419,7 @@ function checkGraphInvariants(
|
|||
});
|
||||
if (
|
||||
canonicalJson(graph.manifests) !==
|
||||
canonicalJson(expectedManifests(graph.entries))
|
||||
canonicalJson(historicalSourceManifests(graph.entries))
|
||||
)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
|
|
|
|||
Loading…
Reference in New Issue