import { PackageInfo } from "./PackageInfo"; import { PackageSource } from "./PackageSource"; /** * Reads package metadata and loads package information from a local source directory. * * This is complicated because the directory structure doesn't correspond to the * packaging structure: There is one package per translator, yet there is one top-level * directory per schema. * * This class supports a git-cloned source directory containing schemas and * translators in the same layout as the git repo. While the directory layout is similar * to an installed package source, there are important differences: * - The npm-installed source has directories separated (and in some cases duplicated) * across packages, while the git source has all directories merged into a single * tree. * - The npm-installed source has a package.json at the root of each package, that * contains pre-built metadata that makes it unnecessary to scan all subdirectories, * while the git source has a package.json for each translator directory, which is * not actually at the root of the package. * * Either way, the PackageSource and PackageInfo classes abstract away the directory * structure from the rest of the library and consumers of it. */ export declare class LocalPackageSource extends PackageSource { /** * Merges OpenT2T package information into a package.json object. */ static mergePackageInfo(packageJson: any, packageInfo: PackageInfo): void; /** * Gets all subdirectories (not files) under a directory. */ protected static getSubdirectoriesAsync(directoryPath: string): Promise; /** * Derive the name of an OpenT2T package. * * @param {string} name Reverse-dns style name of an OpenT2T component * @param {string} type Package type such as "translator" or "onboarding" * @returns {string} Derived NPM package name. */ private static derivePackageName(name, type); /** * Path to the directory where packages are cached. In order to enable requiring * modules in these packages without using relative paths, the path should be a * node_modules directory that is included in the search path. */ readonly sourceDirectory: string; /** * Creates a new LocalPackageSource with a specified cache or source directory. * * @param {string} cacheDirectory Path to the directory where packages are * npm-installed, or path to the root of a cloned OpenT2T source repo. */ constructor(sourceDirectory: string); /** * Gets information about all OpenT2T packages currently available from the source. * CAUTION: This is a potentially slow operation. * * @returns {Promise} An array of package information * objects, or an empty array if the cache is empty */ getAllPackageInfoAsync(): Promise; /** * Gets information about an OpenT2T package from the source * (potentially without downloading the whole package). * * @param {string} name Name of the package * @returns {(Promise; /** * Copies a package to a target directory. * * @param {string} name Name of the package * @param {string} targetDirectory Directory where the package is to be copied */ copyPackageAsync(name: string, targetDirectory: string): Promise; /** * Load schema package information from a schema directory. */ private loadSchemaPackageInfoAsync(schemaName); /** * Load translator package information from package.json and manifest.xml files * in a translator directory. */ private loadTranslatorPackageInfoAsync(schemaName, translatorName); private loadOnboardingPackageInfoAsync(onboardingName); /** * Reads a file and returns the contents parsed as JSON, or null if reading or parsing failed. */ private loadJsonAsync(jsonFilePath); /** * Reads a file and returns the contents parsed as XML, or null if reading or parsing failed. */ private loadXmlAsync(xmlFilePath); }