mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 12:54:29 +00:00
fix(cli): bypass stale cache on tag-based registry lookup (#648)
The add command's tag fallback (e.g. `hyperframes add html-in-canvas`) uses the same 24h cached manifest as single-item lookups. When new items are added to the registry, the stale cache returns an incomplete item list, causing tag resolution to find zero matches. Pass skipCache: true in the tag fallback path so it always fetches the latest manifest from the registry.
This commit is contained in:
@@ -248,7 +248,7 @@ export default defineCommand({
|
||||
|
||||
let items: Awaited<ReturnType<typeof resolveItemsByTag>>;
|
||||
try {
|
||||
items = await resolveItemsByTag(args.name, { baseUrl: config.registry });
|
||||
items = await resolveItemsByTag(args.name, { baseUrl: config.registry, skipCache: true });
|
||||
} catch {
|
||||
items = [];
|
||||
}
|
||||
|
||||
@@ -84,10 +84,13 @@ async function fetchJson<T>(url: string): Promise<T> {
|
||||
*/
|
||||
export async function fetchRegistryManifest(
|
||||
baseUrl: string = DEFAULT_REGISTRY_URL,
|
||||
options?: { skipCache?: boolean },
|
||||
): Promise<RegistryManifest | undefined> {
|
||||
const cacheFile = cachePath(baseUrl, "registry");
|
||||
const cached = readCache<RegistryManifest>(cacheFile);
|
||||
if (cached) return cached;
|
||||
if (!options?.skipCache) {
|
||||
const cached = readCache<RegistryManifest>(cacheFile);
|
||||
if (cached) return cached;
|
||||
}
|
||||
|
||||
try {
|
||||
const manifest = await fetchJson<RegistryManifest>(`${baseUrl}/registry.json`);
|
||||
|
||||
@@ -9,6 +9,8 @@ import { fetchItemManifest, fetchRegistryManifest, DEFAULT_REGISTRY_URL } from "
|
||||
|
||||
export interface ResolveOptions {
|
||||
baseUrl?: string;
|
||||
/** Bypass the 24h manifest cache and fetch fresh data from the registry. */
|
||||
skipCache?: boolean;
|
||||
/**
|
||||
* Called once per item that fails to load inside `loadAllItems`. Defaults
|
||||
* to writing a diagnostic line to stderr. Pass a quieter implementation
|
||||
@@ -30,7 +32,7 @@ export async function listRegistryItems(
|
||||
options: ResolveOptions = {},
|
||||
): Promise<RegistryManifestEntry[]> {
|
||||
const baseUrl = options.baseUrl ?? DEFAULT_REGISTRY_URL;
|
||||
const manifest = await fetchRegistryManifest(baseUrl);
|
||||
const manifest = await fetchRegistryManifest(baseUrl, { skipCache: options.skipCache });
|
||||
if (!manifest) return [];
|
||||
if (!filter?.type) return manifest.items;
|
||||
return manifest.items.filter((item) => item.type === filter.type);
|
||||
|
||||
Reference in New Issue
Block a user