sync-monorepo-packages
Version:
Synchronize files and metadata across packages in a monorepo
58 lines (57 loc) • 2.19 kB
TypeScript
export function createFileCopyResult(from: string, to: string, { err, success }?: FileCopyResultOpts | undefined): Readonly<FileCopyResult>;
export function createPkgChangeResult(pkgPath: string, patch: Operation[], pkg: PackageJson, newPkg?: import("type-fest").PackageJson | undefined): Readonly<PkgChangeResult>;
export type PackageJson = import('type-fest').PackageJson;
export type Operation = import('rfc6902').Operation;
export type FileCopyResultOpts = {
err?: Error | undefined;
success?: boolean | undefined;
};
/**
* Represents the result of a file-copy operation. Do not use directly; use {@linkcode createFileCopyResult} instead.
*/
export class FileCopyResult {
/**
* @param {string} from - Source filepath
* @param {string} to - Destination filepath
* @param {FileCopyResultOpts} [opts] - Options
*/
constructor(from: string, to: string, { err, success }?: FileCopyResultOpts | undefined);
from: string;
to: string;
err: Error | undefined;
success: boolean | undefined;
toString(): string;
/**
* Return a clone of this object, but add an Error
* @param {Error} err - Error
*/
withError(err: Error): Readonly<FileCopyResult>;
/**
* Return a clone of thios object, but mark as successfully copied
*/
withSuccess(): Readonly<FileCopyResult>;
}
/**
* Represents the result of a `package.json` modification
*/
export class PkgChangeResult {
/**
*
* @param {string} pkgPath - Path to destination package.json
* @param {Operation[]} patch - JSON patch
* @param {PackageJson} pkg - Original package.json
* @param {PackageJson} [newPkg] - Updated package.json
*/
constructor(pkgPath: string, patch: Operation[], pkg: PackageJson, newPkg?: import("type-fest").PackageJson | undefined);
pkgPath: string;
patch: import("rfc6902").Operation[];
pkg: import("type-fest").PackageJson;
newPkg: import("type-fest").PackageJson | undefined;
toString(): string;
/**
*
* @param {PackageJson} newPkg
* @returns {Readonly<PkgChangeResult>}
*/
withNewPackage(newPkg: PackageJson): Readonly<PkgChangeResult>;
}