Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/registry/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/registry/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
Loading