9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
42 lines
1.9 KiB
JavaScript
42 lines
1.9 KiB
JavaScript
// homebrew formula — fetch a single Homebrew core formula's metadata.
|
|
//
|
|
// Hits `https://formulae.brew.sh/api/formula/<name>.json`. Returns one row:
|
|
// canonical name, latest stable version, license, dependencies, deprecated /
|
|
// disabled flags, homepage, source tarball URL.
|
|
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
import { BREW_BASE, brewFetch, requireToken } from './utils.js';
|
|
|
|
cli({
|
|
site: 'homebrew',
|
|
name: 'formula',
|
|
access: 'read',
|
|
description: 'Fetch a Homebrew formula\'s metadata (version, license, deps, deprecation, source)',
|
|
domain: 'formulae.brew.sh',
|
|
strategy: Strategy.PUBLIC,
|
|
browser: false,
|
|
args: [
|
|
{ name: 'name', positional: true, required: true, help: 'Formula name (e.g. "wget", "gcc@13", "imagemagick")' },
|
|
],
|
|
columns: ['formula', 'tap', 'version', 'license', 'description', 'homepage', 'dependencies', 'deprecated', 'disabled', 'source', 'url'],
|
|
func: async (args) => {
|
|
const name = requireToken(args.name, 'formula');
|
|
const url = `${BREW_BASE}/formula/${encodeURIComponent(name)}.json`;
|
|
const body = await brewFetch(url, 'homebrew formula');
|
|
const deps = Array.isArray(body?.dependencies) ? body.dependencies.filter(Boolean) : [];
|
|
const stableUrl = String(body?.urls?.stable?.url ?? '').trim();
|
|
return [{
|
|
formula: String(body?.name ?? name).trim(),
|
|
tap: String(body?.tap ?? '').trim(),
|
|
version: String(body?.versions?.stable ?? '').trim(),
|
|
license: String(body?.license ?? '').trim(),
|
|
description: String(body?.desc ?? '').trim(),
|
|
homepage: String(body?.homepage ?? '').trim(),
|
|
dependencies: deps.join(', '),
|
|
deprecated: Boolean(body?.deprecated),
|
|
disabled: Boolean(body?.disabled),
|
|
source: stableUrl,
|
|
url: `https://formulae.brew.sh/formula/${encodeURIComponent(name)}`,
|
|
}];
|
|
},
|
|
});
|