bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
41 lines (40 loc) • 2.25 kB
TypeScript
import { PathOsBased, PathOsBasedRelative, PathOsBasedAbsolute, PathRelative } from '../../utils/path';
import Component from './consumer-component';
import PackageJsonVinyl from './package-json-vinyl';
import { Capsule } from '../../extensions/isolator';
export default class PackageJsonFile {
packageJsonObject: Record<string, any>;
fileExist: boolean;
filePath: PathOsBasedRelative;
workspaceDir: PathOsBasedAbsolute | null | undefined;
indent: string | null | undefined;
newline: string | null | undefined;
constructor({ filePath, packageJsonObject, fileExist, workspaceDir, indent, newline }: {
filePath: PathOsBasedRelative;
packageJsonObject?: Record<string, any>;
fileExist: boolean;
workspaceDir?: PathOsBasedAbsolute;
indent?: string;
newline?: string;
});
write(): Promise<void>;
static load(workspaceDir: PathOsBasedAbsolute, componentDir?: PathRelative): Promise<PackageJsonFile>;
static loadSync(workspaceDir: PathOsBasedAbsolute, componentDir?: PathRelative): PackageJsonFile;
static loadFromPathSync(workspaceDir: PathOsBasedAbsolute, pathToLoad: string): PackageJsonFile;
static loadFromCapsuleSync(capsule: Capsule): PackageJsonFile;
static createFromComponent(componentDir: PathRelative, component: Component, excludeRegistryPrefix?: boolean | undefined): PackageJsonFile;
toVinylFile(): PackageJsonVinyl;
addDependencies(dependencies: Record<string, any>): void;
addDevDependencies(dependencies: Record<string, any>): void;
removeDependency(dependency: string): void;
replaceDependencies(dependencies: Record<string, any>): void;
addOrUpdateProperty(propertyName: string, propertyValue: any): void;
getProperty(propertyName: string): any;
setPackageManager(packageManager: string | undefined): void;
mergePackageJsonObject(packageJsonObject: Record<string, any> | null | undefined): void;
clone(): PackageJsonFile;
static propsNonUserChangeable(): string[];
static parsePackageJsonStr(str: string, dir: string): any;
static getPackageJsonStrIfExist(filePath: PathOsBased): Promise<string | null>;
static getPackageJsonStrIfExistSync(filePath: PathOsBased): string | null;
}