import { getMatches } from "../file-matching.js";
import { defineSource } from "../source.js";
import { readFile } from "node:fs/promises";
import { resolve } from "node:path";
import { parsePackage } from "read-pkg";
//#region src/lib/sources/node-package-json.ts
/**
* Parse package.json content and return structured metadata.
*/
function parse(content) {
	return parsePackage(content);
}
const nodePackageJsonSource = defineSource({
	async discover(context) {
		return getMatches(context.options, ["package.json"]);
	},
	key: "nodePackageJson",
	async parse(input, context) {
		return {
			data: parse(await readFile(resolve(context.options.path, input), "utf8")),
			source: input
		};
	},
	phase: 1
});
//#endregion
export { nodePackageJsonSource };
