UNPKG

3.05 kBTypeScriptView Raw
1import { PackageJsonLookup, NewlineKind, INodePackageJson } from '@rushstack/node-core-library';
2import { MessageRouter } from '../collector/MessageRouter';
3/**
4 * Represents analyzed information for a package.json file.
5 * This object is constructed and returned by PackageMetadataManager.
6 */
7export declare class PackageMetadata {
8 /**
9 * The absolute path to the package.json file being analyzed.
10 */
11 readonly packageJsonPath: string;
12 /**
13 * The parsed contents of package.json. Note that PackageJsonLookup
14 * only includes essential fields.
15 */
16 readonly packageJson: INodePackageJson;
17 /**
18 * If true, then the package's documentation comments can be assumed
19 * to contain API Extractor compatible TSDoc tags.
20 */
21 readonly aedocSupported: boolean;
22 constructor(packageJsonPath: string, packageJson: INodePackageJson, aedocSupported: boolean);
23}
24/**
25 * This class maintains a cache of analyzed information obtained from package.json
26 * files. It is built on top of the PackageJsonLookup class.
27 *
28 * @remarks
29 *
30 * IMPORTANT: Don't use PackageMetadataManager to analyze source files from the current project:
31 * 1. Files such as tsdoc-metadata.json may not have been built yet, and thus may contain incorrect information.
32 * 2. The current project is not guaranteed to have a package.json file at all. For example, API Extractor can
33 * be invoked on a bare .d.ts file.
34 *
35 * Use ts.program.isSourceFileFromExternalLibrary() to test source files before passing the to PackageMetadataManager.
36 */
37export declare class PackageMetadataManager {
38 static tsdocMetadataFilename: string;
39 private readonly _packageJsonLookup;
40 private readonly _messageRouter;
41 private readonly _packageMetadataByPackageJsonPath;
42 constructor(packageJsonLookup: PackageJsonLookup, messageRouter: MessageRouter);
43 private static _resolveTsdocMetadataPathFromPackageJson;
44 /**
45 * @param tsdocMetadataPath - An explicit path that can be configured in api-extractor.json.
46 * If this parameter is not an empty string, it overrides the normal path calculation.
47 * @returns the absolute path to the TSDoc metadata file
48 */
49 static resolveTsdocMetadataPath(packageFolder: string, packageJson: INodePackageJson, tsdocMetadataPath?: string): string;
50 /**
51 * Writes the TSDoc metadata file to the specified output file.
52 */
53 static writeTsdocMetadataFile(tsdocMetadataPath: string, newlineKind: NewlineKind): void;
54 /**
55 * Finds the package.json in a parent folder of the specified source file, and
56 * returns a PackageMetadata object. If no package.json was found, then undefined
57 * is returned. The results are cached.
58 */
59 tryFetchPackageMetadata(sourceFilePath: string): PackageMetadata | undefined;
60 /**
61 * Returns true if the source file is part of a package whose .d.ts files support AEDoc annotations.
62 */
63 isAedocSupportedFor(sourceFilePath: string): boolean;
64}
65//# sourceMappingURL=PackageMetadataManager.d.ts.map
\No newline at end of file