@salesforce/source-deploy-retrieve
Version:
JavaScript library to run Salesforce metadata deploys and retrieves
53 lines (52 loc) • 2.85 kB
TypeScript
import { Transform, Readable } from 'node:stream';
import { SourcePath } from '../common/types';
import { SourceComponent } from '../resolve/sourceComponent';
import { MarkedReplacement, ReplacementConfig } from './types';
/** If a component has replacements, you get it piped through the replacementStream
* Otherwise, you'll get the original readable stream
* Ignore binary files, they will get corrupted in the replacement process
*/
export declare const getReplacementStreamForReadable: (component: SourceComponent, path: SourcePath) => Readable | ReplacementStream;
/**
* A stream for replacing the contents of a single SourceComponent.
*
*/
declare class ReplacementStream extends Transform {
private readonly replacements;
constructor(replacements: MarkedReplacement[]);
_transform(chunk: Buffer, encoding: string, callback: (error?: Error, data?: Buffer) => void): Promise<void>;
}
/**
* perform an array of replacements on a string
* emits warnings when an expected replacement target isn't found
*/
export declare const replacementIterations: (input: string, replacements: MarkedReplacement[]) => Promise<string>;
/**
* Reads the project, gets replacements, removes any that aren't applicable due to environment conditionals, and returns an instance of the ReplacementMarkingStream
*/
export declare const getReplacementMarkingStream: (projectDir?: string) => Promise<ReplacementMarkingStream | undefined>;
/**
* Stream for marking replacements on a component.
* Returns a mutated component with a `replacements` property if any replacements are found.
* Throws if any replacements reference a file or env that does not exist
*/
declare class ReplacementMarkingStream extends Transform {
private readonly replacementConfigs;
constructor(replacementConfigs: ReplacementConfig[]);
_transform(chunk: SourceComponent, encoding: string, callback: (err: Error | undefined, data: SourceComponent) => void): Promise<void>;
}
export declare const getContentsOfReplacementFile: (path: string) => Promise<string>;
/**
* Build the replacements property for a sourceComponent
*/
export declare const getReplacements: (cmp: SourceComponent, replacementConfigs?: ReplacementConfig[]) => Promise<SourceComponent["replacements"] | undefined>;
export declare const matchesFile: (filename: string) => (r: ReplacementConfig) => boolean;
/**
* Regardless of any components, return the ReplacementConfig that are valid with the current env.
* These can be checked globally and don't need to be checked per component.
*/
export declare const envFilter: (replacement: ReplacementConfig) => boolean;
/** escape any special characters used in the string so it can be used as a regex */
export declare const stringToRegex: (input: string) => RegExp;
export declare const posixifyPaths: (f: string) => string;
export {};