MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / loadCatalogs

Function loadCatalogs

packages/bumpy/src/utils/package-manager.ts:167–186  ·  view source on GitHub ↗

Load catalog definitions from the package manager's workspace YAML and/or root package.json

(rootDir: string, pm: PackageManager)

Source from the content-addressed store, hash-verified

165
166/** Load catalog definitions from the package manager's workspace YAML and/or root package.json */
167async function loadCatalogs(rootDir: string, pm: PackageManager): Promise<CatalogMap> {
168 // Only the package manager's own YAML file is consulted (pnpm-workspace.yaml
169 // for pnpm, .yarnrc.yml for Yarn) — other PMs don't recognize it.
170 let workspaceYaml: string | null = null;
171 const yamlFile = catalogYamlFile(pm);
172 if (yamlFile) {
173 const wsFile = resolve(rootDir, yamlFile);
174 if (await exists(wsFile)) {
175 workspaceYaml = await readText(wsFile);
176 }
177 }
178
179 let pkgJsonText: string | null = null;
180 const pkgJsonPath = resolve(rootDir, 'package.json');
181 if (await exists(pkgJsonPath)) {
182 pkgJsonText = await readText(pkgJsonPath);
183 }
184
185 return parseCatalogs(workspaceYaml, pkgJsonText);
186}
187
188/** Extract the catalog name from a `catalog:` / `catalog:<name>` range, normalizing the default alias */
189function catalogNameFromRange(range: string): string {

Callers 1

detectWorkspacesFunction · 0.85

Calls 4

existsFunction · 0.90
readTextFunction · 0.90
catalogYamlFileFunction · 0.85
parseCatalogsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…