discoverManifest
Generated reference page for the discoverManifest function export.
- Import:
@kjanat/dreamcli - Export kind: function
- Declared in:
src/core/config/package-json.ts - Source link:
src/core/config/package-json.ts:195
Signatures
function discoverManifest(adapter: PackageJsonAdapter, options: ManifestDiscoveryOptions): Promise<PackageJsonData | null>;| Parameter | Type | Description |
|---|---|---|
adapter | PackageJsonAdapter | Adapter providing readFile + cwd. |
options | ManifestDiscoveryOptions = {} | Optional anchor (startDir) and candidate filenames (files). |
Members
Members
discoverManifest
Discover the nearest manifest (package.json, deno.json, jsr.json, …) by walking up from startDir (or adapter.cwd when omitted).
Convenience helper behind CLIBuilder.manifest(). Most apps should let the CLI runtime discover metadata automatically; call this directly when testing metadata inference or embedding the behavior in custom tooling.
Candidate files are parsed as JSON with a JSONC fallback — package.json, deno.json, jsr.json, and deno.jsonc all qualify, including files that carry // / block comments or trailing commas (common in deno.json). A file that fails both parses is skipped, so discovery keeps probing.
Returns the parsed metadata on success, null when no manifest is found (not an error). Malformed JSON, non-object roots, and config-only manifests that carry no recognised metadata (e.g. a deno.json with only tasks / imports) are all skipped, so discovery keeps probing the remaining candidate files and parent directories — the feature is a convenience, not a hard requirement.
(adapter: PackageJsonAdapter, options: ManifestDiscoveryOptions): Promise<PackageJsonData | null>;Examples
import { discoverManifest } from '@kjanat/dreamcli';
const meta = await discoverManifest(adapter, { files: ['deno.json', 'jsr.json'] });
if (meta !== null) {
console.log(meta.version); // '1.2.3'
}