/** * @file Npm.Effect.ts * @author Gage Sorrell * @copyright (c) 2026 Gage Sorrell * @license MIT */ import type { EGetDependencies, EGetDependencyPackage, EGetNodeModulesPath, EGetPackageJson, EGetPackageRootDirectory, PackageDependency } from "./Npm.Effect.Types.ts"; /** * Get the `package.json` of the Node.js project in which the * given path, or the current working directory, resides. * * @param SearchStart - The given path from which to look for a root directory. * * @returns {EGetPackageJson} An Effect that succeeds with the parsed `package.json`, or fails * with {@link RootDirectoryNotFoundError} or {@link PackageJsonParseError}. * * @example * Suppose `process.cwd() === "./MyPackage"`, * ```typescript * Effect.gen(function* () * { * const PackageJson: IPackageJson = yield* GetPackageJson(); * // `PackageJson` <- *The parsed `package.json` of `MyPackage`.* * } * ``` */ export declare function GetPackageJson(SearchStart?: string): EGetPackageJson; /** * Get the root directory of the Node.js project in which the * current working directory resides. * * @param SearchStart - If specified, this is the given path from which to look for a root directory. * Otherwise, the search is started from {@link process.cwd}. * * @returns {EGetPackageRootDirectory} An Effect that succeeds with the package root * directory, or fails with {@link RootDirectoryNotFoundError}. * * @example * Suppose `process.cwd()` is any one of the following, * - `/home/alex/myPackage`, * - `/home/alex/myPackage/src/MyModule`, * - `/home/alex/myPackage/resource/Images`, * * then, * * ```typescript * import { Effect } from "effect"; * const Root: string = await Effect.runPromise(GetPackageRootDirectory()); * // `Root` <- `"/home/alex/myPackage"` * ``` * * @example * Suppose `TestPath === "/home/alex/Documents"` is *not* a NodeJS package root * (of course, neither are `/home/alex` or `/home`). Then, * * ```typescript * import { Effect } from "effect"; * const TestPath: string = "/home/alex/Documents"; * let Root: string | undefined = undefined; * try * { * Root = await Effect.runPromise( * GetPackageRootDirectory(TestPath) * ); * } * catch (Error: unknown) * { * // `Error instanceof RootDirectoryNotFound` * } * * // `Root` <- `undefined` * ``` * * @example * Suppose `process.cwd() === /home/alex/Downloads`, which is *not* a NodeJS package * (of course, neither are `/home/alex` or `/home`). Then, * * ```typescript * import { Effect } from "effect"; * let Root: string | undefined = undefined; * try * { * Root = await Effect.runPromise(GetPackageRootDirectory()); * } * catch (Error: unknown) * { * // `Error instanceof RootDirectoryNotFound` * } * // `Root` <- `undefined` * ``` */ export declare function GetPackageRootDirectory(SearchStart?: string): EGetPackageRootDirectory; /** * For a given `npm` package, identified by a {@link Cwd} path contained by the `npm` package, * get the path to the `node_modules` directory that contains the dependencies of the package. * * @note This supports `npm` workspaces, and has not been tested with packages that are workspaces * of packages handled by *other* package managers. * * @param Cwd - The path of a directory within an `npm` package (possibly * the root directory of the package). * * @returns {EGetNodeModulesPath} An {@link Effect.Effect | effect} that finds the * `node_modules` directory of an `npm` package that contains the given {@link Cwd}. */ export declare function GetNodeModulesDirectory(Cwd?: string): EGetNodeModulesPath; /** * For a given `npm` package, identified by a {@link Directory} path contained by the `npm` package * and whose dependencies are installed on the current file system, and for a given {@link Dependency} * of that package, get the {@link IPackageJson | package.json} of the given dependency in the `node_modules` * directory that contains the dependencies of the given package. * * @note This supports `npm` workspaces, and has not been tested with packages that are workspaces * of packages handled by *other* package managers. * * @param Dependency - The name of the dependency whose {@link IPackageJson | package.json} is returned * by this. * * @param Directory - The path of a directory within an `npm` package (possibly * the root directory of the package). * * @returns {EGetDependencyPackage} An {@link Effect.Effect | effect} that returns * the {@link IPackageJson | package.json} of the given {@link Dependency}, for * the `npm` package identified by the given {@link Directory}. */ export declare function GetDependencyPackage(Dependency: string, Directory?: string): EGetDependencyPackage; /** * For a NodeJS project containing {@link SearchStart | a given directory}, get the names of its dependencies. * * @param Dependencies - If specified, then the "types" of dependencies to include, where each "type" * is identified by its key in the `package.json` file. Otherwise, this is `"dependencies"` and * `"devDependencies"`. * * @param SearchStart - If specified, the path from which the search for the `package.json` will begin. * Otherwise, it is {@link process!cwd}. * * @returns {EGetDependencies} An {@link Effect!Effect | effect} that returns the dependencies * of the package containing the given {@link SearchStart} */ export declare function GetDependencies(Dependencies?: ReadonlyArray, SearchStart?: string): EGetDependencies; //# sourceMappingURL=Npm.Effect.d.ts.map