mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
refactor(kernel): migrate the remaining SHA-256 hex digests to sha256Hex and move isRecord into src/kernel (#11571)
* refactor(kernel): migrate the remaining one-shot SHA-256 hex digests to sha256Hex * refactor(kernel): move isRecord into src/kernel and replace its inline copies (#11574) * fix(scripts): import isRecord from src/kernel in the managed manifest parser
This commit is contained in:
1 parent
9ecfb109e8
commit
b51ed4c3ec
157 files changed
+397
-589
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import { boundedList } from "../../domain/boundedList.js";
|
||||
import { createHash } from "node:crypto";
|
||||
import { posix } from "node:path";
|
||||
|
||||
import { setImmediate } from "node:timers/promises";
|
||||
@@ -57,6 +56,7 @@ import {
|
||||
cancelledBy,
|
||||
carriedReason,
|
||||
} from "../../domain/analysisErrorCore.js";
|
||||
import { sha256Hex } from "../../kernel/sha256Hex.js";
|
||||
|
||||
interface MutableArtifactAnalysis {
|
||||
readonly jsonDocuments: JavaScriptJsonDocuments;
|
||||
@@ -700,7 +700,7 @@ const collectSourceMapOriginals = (
|
||||
declaration_index: declarationIndex++,
|
||||
reference,
|
||||
content,
|
||||
content_sha256: content === null ? null : sha256(content),
|
||||
content_sha256: content === null ? null : sha256Hex(content),
|
||||
section_path,
|
||||
});
|
||||
}
|
||||
@@ -786,6 +786,3 @@ const findingCount = (analysis: JavaScriptStaticAnalysis): number =>
|
||||
|
||||
const optionalString = (value: unknown): string | null =>
|
||||
typeof value === "string" && value.length > 0 ? value : null;
|
||||
|
||||
const sha256 = (value: string): string =>
|
||||
createHash("sha256").update(value).digest("hex");
|
||||
@@ -1,4 +1,3 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { posix } from "node:path";
|
||||
|
||||
import { compactStringIdentityKey } from "../../domain/compactStringIdentity.js";
|
||||
@@ -38,6 +37,7 @@ import {
|
||||
isJsonModuleTarget,
|
||||
isNativeAddonModuleTarget,
|
||||
} from "../../domain/javascript/javascriptModuleResolutionMode.js";
|
||||
import { sha256Hex } from "../../kernel/sha256Hex.js";
|
||||
|
||||
type StaticReference = JavaScriptStaticAnalysis["references"][number];
|
||||
type StaticEndpoint = JavaScriptStaticAnalysis["endpoints"][number];
|
||||
@@ -666,9 +666,7 @@ const addSourceMapEdge = (
|
||||
context: JavaScriptArtifactGraphContext,
|
||||
input: FindingInput<StaticSourceMap>,
|
||||
): void => {
|
||||
const declaredUrlSha256 = createHash("sha256")
|
||||
.update(input.value.declared_url)
|
||||
.digest("hex");
|
||||
const declaredUrlSha256 = sha256Hex(input.value.declared_url);
|
||||
const resolution = resolveArtifactPathByContext({
|
||||
declaredPath: input.value.declared_url,
|
||||
sourcePath: input.file.path,
|
||||
|
||||
@@ -36,6 +36,7 @@ import { selectPackageSubpathPattern } from "../../domain/javascript/javascriptP
|
||||
import type { JavaScriptModuleResolutionMode } from "../../domain/javascript/javascriptModuleResolutionMode.js";
|
||||
import type { JsonValue } from "../../domain/jsonValue.js";
|
||||
import { err, ok, type Result } from "../../domain/result.js";
|
||||
import { isRecord } from "../../kernel/isRecord.js";
|
||||
|
||||
type ArtifactPathResolutionContext =
|
||||
| "package-entrypoint"
|
||||
@@ -1502,10 +1503,7 @@ const readPackageMetadata = (
|
||||
? exports
|
||||
: undefined,
|
||||
// Import maps must be non-array objects; other shapes are not a map.
|
||||
imports:
|
||||
typeof imports === "object" && imports !== null && !Array.isArray(imports)
|
||||
? imports
|
||||
: undefined,
|
||||
imports: isRecord(imports) ? imports : undefined,
|
||||
main:
|
||||
input.moduleKind !== undefined && typeof main !== "string"
|
||||
? undefined
|
||||
@@ -1851,7 +1849,7 @@ const selectPackageExport = (
|
||||
let target = value;
|
||||
let pattern: string | undefined;
|
||||
let declared: string[] = [];
|
||||
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
||||
if (isRecord(value)) {
|
||||
const keys = Object.keys(value);
|
||||
const hasSubpaths = keys.some((key) => key.startsWith("."));
|
||||
if (hasSubpaths && keys.some((key) => !key.startsWith(".")))
|
||||
|
||||
Reference in new issue
Block a user