mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-14 21:29:34 +00:00
refactor: address simplify review feedback on registry module
Applied a pass of review feedback that concentrates on correctness,
shared constants, and cleanup.
- Lift ITEM_TYPE_DIRS to @hyperframes/core/registry. Replaces an
exhaustiveness-fragile switch in remote.ts and the hardcoded
"examples" literal in scripts/generate-registry-items.ts. One
constant, three consumers, checked against the ItemType union.
- remote.ts readCache: drop existsSync pre-check (TOCTOU double
syscall) and rely on the existing try/catch for cache miss.
- templates/remote.ts: hoist the listRegistryItems/loadAllItems
dynamic import to static — had no reason to be async-lazy.
- resolver.ts loadAllItems: accept an optional onWarn callback
instead of calling console.warn directly. Default writes to stderr
with a "hyperframes:registry" prefix so structured output (JSON,
clack prompts) can opt in to silence.
- Scrub PR-number references from inline comments in the registry
and compat-shim files. Intent language instead ("future item types",
"compat shim for legacy init.ts callers").
- Fix stale test description in remote.test.ts that claimed PR 3
renamed MANIFEST_FILENAME to registry.json (the rename didn't
happen — the filename stays templates.json for the compat shim).
Skipped (documented as intentional in PR thread):
- Lifting assertSafeTarget to @hyperframes/core — CLI-specific
concern, keeps core lean
- Extracting readCache/writeCache to utils/cache.ts — one consumer
today; revisit when the CLI gets a second
- Hashing the cache-key slug — theoretical collision for a single-
digit registry count; revisit when PR 14 adds custom registries
- Removing assertSafeTarget's layered checks — reviewer confirmed
defense-in-depth is worth keeping for diagnostic clarity
Core: 452 tests pass. CLI: 70 tests pass (4 pre-existing failures
unchanged, unrelated to this PR). Format + lint clean.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
James Russo
co-authored by
Claude Opus 4.6
parent
c5f0ab3f76
commit
5ed196c53a
@@ -18,11 +18,17 @@
|
||||
import { readFileSync, writeFileSync, readdirSync, statSync } from "node:fs";
|
||||
import { join, relative, resolve, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import type { FileTarget, FileType, RegistryItem, RegistryManifest } from "@hyperframes/core";
|
||||
import {
|
||||
ITEM_TYPE_DIRS,
|
||||
type FileTarget,
|
||||
type FileType,
|
||||
type RegistryItem,
|
||||
type RegistryManifest,
|
||||
} from "@hyperframes/core";
|
||||
|
||||
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||
const repoRoot = resolve(scriptDir, "..");
|
||||
const examplesDir = resolve(repoRoot, "registry/examples");
|
||||
const examplesDir = resolve(repoRoot, "registry", ITEM_TYPE_DIRS["hyperframes:example"]);
|
||||
const registryManifestPath = resolve(repoRoot, "registry/registry.json");
|
||||
const legacyManifestPath = resolve(examplesDir, "templates.json");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user