UNPKG

@salesforce/source-deploy-retrieve

Version:

JavaScript library to run Salesforce metadata deploys and retrieves

60 lines (59 loc) 3.17 kB
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. * Tracks which replacements were found across all chunks and emits warnings only at the end. */ export declare class ReplacementStream extends Transform { private readonly replacements; private readonly foundReplacements; private readonly allReplacements; private readonly lifecycleInstance; constructor(replacements: MarkedReplacement[]); _transform(chunk: Buffer, encoding: string, callback: (error?: Error, data?: Buffer) => void): Promise<void>; _flush(callback: (error?: Error) => void): Promise<void>; } /** * perform an array of replacements on a string * returns both the replaced string and a Set of found replacements */ export declare const replacementIterations: (input: string, replacements: MarkedReplacement[]) => Promise<{ output: string; found: Set<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 {};