@callstack/react-native-legal-shared
Version:
Shared code for all packages
72 lines (71 loc) • 3.5 kB
TypeScript
import type { AboutLibrariesLikePackageInfo, AggregatedLicensesObj, ScanPackageOptionsFactory } from './types';
/**
* Scans `package.json` and searches for all packages under `dependencies` field. Supports monorepo projects.
*
* @param appPackageJsonPath Path to the `package.json` file of the application
* @param scanOptionsFactory Factory function to create scan options for dependencies; defaults to {@link PackageUtils.legacyDefaultScanPackageOptionsFactory}
* @returns Aggregated licenses object containing all scanned dependencies and their license information
*/
export declare function scanDependencies(appPackageJsonPath: string, scanOptionsFactory?: ScanPackageOptionsFactory): AggregatedLicensesObj;
/**
* Generates LicensePlist-compatible metadata for NPM dependencies as a YAML string.
*
* To write a file directly, use `writeLicensePlistNPMOutput` function.
*
* @param licenses Scanned NPM licenses
* @param iosProjectPath Path to the iOS project directory
* @see {@link writeLicensePlistNPMOutput}
*/
export declare function generateLicensePlistNPMOutput(licenses: AggregatedLicensesObj, iosProjectPath: string): string;
/**
* Writes LicensePlist-compatible metadata for NPM dependencies to a file
*
* This will take scanned NPM licenses and produce following output inside iOS project's directory:
*
* ```
* | - ios
* | ---- myawesomeapp
* | ---- myawesomeapp.xcodeproj
* | ---- myawesomeapp.xcodeworkspace
* | ---- license_plist.yml <--- generated LicensePlist config with NPM dependencies
* | ---- Podfile
* | ---- Podfile.lock
* ```
*
* @param licenses Scanned NPM licenses
* @param iosProjectPath Path to the iOS project directory
* @param plistLikeOutput Optional pre-generated string output to use instead of generating it using `generateLicensePlistNPMOutput`
* @see {@link generateLicensePlistNPMOutput}
*/
export declare function writeLicensePlistNPMOutput(licenses: AggregatedLicensesObj, iosProjectPath: string, plistLikeOutput?: string): void;
/**
* Generates AboutLibraries-compatible metadata for NPM dependencies
*
* This will take scanned NPM licenses and produce output that can be modified and/or written to the Android project files.
*
* @param licenses Scanned NPM licenses
* @returns Array of AboutLibrariesLikePackage objects, each representing a NPM dependency
* @see {@link writeAboutLibrariesNPMOutput}
*/
export declare function generateAboutLibrariesNPMOutput(licenses: AggregatedLicensesObj): AboutLibrariesLikePackageInfo[];
/**
* Generates AboutLibraries-compatible metadata for NPM dependencies
*
* This will take scanned NPM licenses and produce following output inside android project's directory:
*
* ```
* | - android
* | ---- app
* | ---- config <--- generated AboutLibraries config directory
* | ------- libraries <--- generated directory with JSON files list of NPM dependencies
* | ------- licenses <--- generated directory with JSON files list of used licenses
* | ---- build.gradle
* | ---- settings.gradle
* ```
*
* @param licenses Scanned NPM licenses
* @param androidProjectPath Path to the Android project directory
* @param aboutLibrariesLikeOutput Optional pre-generated output to use instead of generating it using `generateAboutLibrariesNPMOutput`
* @see {@link generateAboutLibrariesNPMOutput}
*/
export declare function writeAboutLibrariesNPMOutput(licenses: AggregatedLicensesObj, androidProjectPath: string, aboutLibrariesLikeOutput?: AboutLibrariesLikePackageInfo[]): void;