import { Blob } from 'buffer'; import type { ChildProcess } from 'child_process'; import { CoreModels } from './core-models'; import { UtilsFilesFoldersSync } from './utils-files-folders'; export interface RunSyncOrAsyncOptions { functionFn: Function; context?: object; arrayOfParams?: any[]; } export interface CommandOutputOptions { biggerBuffer?: boolean; showOnlyLastLine?: boolean; showStder?: boolean; gatherColors?: boolean; showErrorWarning?: boolean; } export declare namespace Helpers { const getIsBrowser: () => boolean; const getIsWebSQL: () => boolean; const getIsNode: () => boolean; const getIsElectron: () => boolean; const contain: (arr: any[], item: any) => boolean; const msgCacheClear: () => void; const renderError: (err: Error) => void; const throwError: (details: string) => never; const stopApplication: (details: string) => never; const tryCatchError: (error: any) => void; const error: (details: any, noExit?: boolean, noTrace?: boolean) => void; const info: (details: string, repeatable?: boolean) => void; const success: (details: any | string) => void; const taskStarted: (details: any | string, isLogTask?: boolean) => void; const taskDone: (details?: any | string, isLessImportant?: boolean) => void; const getIsVerboseMode: () => boolean; const log: (details: any, debugLevel?: number, skipVisibleConditionChecking?: boolean) => void; const logSuccess: (details: any | string) => void; const logInfo: (details: string, repeatable?: boolean) => void; const logError: (details: any, noExit?: boolean, noTrace?: boolean) => void; const logWarn: (details: string, trace?: boolean) => void; const warn: (details: string, trace?: boolean) => void; const bigMaxBuffer: number; const getIsWsl: () => boolean; const isRunningInDocker: () => boolean; const isRunningInLinuxGraphicsCapableEnvironment: () => boolean; const clearConsole: () => void; const mediaTypeFromSrc: (src: string) => CoreModels.MediaType; /** * @deprecated use async Utils.wait * * Helpers.sleep(2) => await Utils.wait(2) */ const sleep: (seconds?: number) => void; const removeIfExists: (absoluteFileOrFolderPath: string | string[]) => void; const relative: (cwd: string, to: string) => string; const removeFileIfExists: (absoluteFilePath: string | string[]) => void; const removeFolderIfExists: (absoluteFolderPath: string | string[]) => void; /** * leave max 1 empty line */ const removeEmptyLineFromString: (str: string) => string; /** * @deprecated */ const tryRemoveDir: (dirpath: string, contentOnly?: boolean, omitWarningNotExisted?: boolean) => void; const removeSymlinks: (dirPath: string | string[], options?: { dryRun?: boolean; }) => void; const remove: (fileOrFolderPathOrPatter: string | string[], exactFolder?: boolean) => void; const cleanExit: () => never; const getIsRunningInGitBash: () => boolean; /** * Check if the current shell is supported by Taon framework. */ const getIsSupportedTaonTerminal: () => boolean; /** * check if function is class */ const isClass: (funcOrClass: any) => boolean; /** * check if data is nodejs/browser blob * * @param maybeBlob */ const isBlob: (maybeBlob: any) => maybeBlob is Blob; /** * Check if data is nodejs buffer * * @param maybeNodejsBuffer * @returns */ const isBuffer: (maybeNodejsBuffer: any) => maybeNodejsBuffer is Buffer; const removeSlashAtEnd: (s: string) => string; const removeSlashAtBegin: (s: string) => string; const stringify: (inputObject: any) => string; /** * @deprecated */ const runSyncOrAsync: (fnOrOptions: RunSyncOrAsyncOptions) => Promise; const createSymLink: (existedFileOrFolder: string, destinationPath: string, options?: { /** * try to remove destination path before create link */ tryRemoveDesPath?: boolean; /** * if folder doesn't exist, just continue */ continueWhenExistedFolderDoesntExists?: boolean; /** * create windows hard link instead of symlink */ windowsHardLink?: boolean; /** * don't rename destination path when slash at the end */ dontRenameWhenSlashAtEnd?: boolean; allowNotAbsolutePathes?: boolean; /** * only if you know that symlink can be created */ speedUpProcess?: boolean; }) => void; const createFolder: (folderPath: string | string[]) => void; const mkdirp: (folderPath: string | string[]) => void; /** * symlink may have existed or unexisted destiantion url */ const isSymlinkThatMatchesUrl: (possibleSymlink: string, destUrl: string, absoluteFileMatch?: boolean) => boolean; const isSymlinkFileExitedOrUnexisted: (filePath: string | string[]) => boolean; /** * If symbolnk link that target file does not exits */ const isUnexistedLink: (filePath: string | string[]) => boolean; /** * @param existedLink check if source of link exists */ const isExistedSymlink: (filePath: string | string[]) => boolean; const pathContainLink: (p: string) => boolean; const exists: (folderOrFilePath: string | string[]) => boolean; /** * TODO QUICK_FIX this is HACK for running procesess inside processes */ const _fixCommand: (command: string) => string; const command: (command: string) => { getherOutput(options?: { ommitStder?: boolean; cwd?: string; biggerBuffer?: boolean; gatherColors?: boolean; }): Promise; }; /** * @deprecated use UtilsTerminal.wait */ const wait: (second: number) => Promise; const timeout: (seconds: number) => Promise; const commandOutputAsStringAsync: (command: string, cwd?: string, options?: CommandOutputOptions) => Promise; const commandOutputAsString: (command: string, cwd?: string, options?: CommandOutputOptions) => string; /** * @deprecated use UtilsProcess.killProcessOnPort */ const killProcessByPort: (portOrPortsToKill: number | number[], options?: { silent?: boolean; }) => Promise; const killOnPort: (portOrPortsToKill: number | number[], options?: { silent?: boolean; }) => Promise; /** * @deprecated use UtilsProcess.killProcess */ const killProcess: (byPid: number) => void; /** * @deprecated use UtilsProcess * or native child_process exec, spawn */ const run: (command: string, options?: CoreModels.RunOptions) => { /** * start command as synchronous nodej proces */ sync(): string; /** * start command as asynchronous nodej proces * @param detach (default: false) - if true process will be detached */ async(detach?: boolean, mockFun?: (stdoutCallback: (dataForStdout: any) => any, stdErrcCallback: (dataForStder: any) => any, shouldProcesBeDead?: () => boolean) => Promise | number): ChildProcess; /** * start command as asynchronous nodej proces inside promise */ asyncAsPromise(): Promise; unitlOutput(optionsOutput: { stdoutMsg: string | string[]; stderMsg?: string | string[]; timeout?: number; stdoutOutputContainsCallback?: () => any; outputLineReplace?: (outputLine: string) => string; }): Promise; /** * @deprecated use unitlOutput * start command as asynchronous nodej proces inside promise * and wait until output contains some string */ unitlOutputContains(stdoutMsg: string | string[], stderMsg?: string | string[], timeout?: number, stdoutOutputContainsCallback?: () => any): Promise; }; /** * @deprecated use UtilsTerminal.confirm */ const questionYesNo: (message: string, callbackTrue?: () => any, callbackFalse?: () => any, defaultValue?: boolean) => Promise; const getStdio: (options?: CoreModels.RunOptions) => any; const runSyncIn: (command: string, options?: CoreModels.RunOptions) => string; const runAsyncIn: (command: string, options?: CoreModels.RunOptions) => ChildProcess; const logProc: (proc: ChildProcess, output: boolean, stdio: any, outputLineReplace: (outputLine: string) => string, prefix: string, extractFromLine?: (string | Function)[]) => ChildProcess; /** * @deprecated use UtilsProcess.startAsync */ const execute: (command: string, cwd: string, options?: Omit) => Promise; /** * @deprecated */ const checkProcess: (dirPath: string, command: string) => void; const modifyLineByLine: (data: string | Buffer | Error, outputLineReplace: (outputLine: string) => string, prefix: string, extractFromLine?: (string | Function)[]) => string; const isFolder: (pathToFileOrMaybeFolder: string) => boolean; /** * Quick fix for object values * @deprecated */ const values: (obj: any) => any[]; /** * does not make sense * @deprecated */ const isFile: (pathToFileOrMaybeFolder: string) => boolean; const tryReadFile: (absoluteFilePath: string | string[], // @ts-ignore defaultValueWhenNotExists?: string, notTrim?: boolean) => Promise; /** * @deprecated use UtilsFilesFoldersSync.readFile * wrapper for fs.readFileSync */ const readFile: (absoluteFilePath: string | string[], // @ts-ignore defaultValueWhenNotExists?: string, notTrim?: boolean) => string | undefined; /** * @deprecated use UtilsJson.readJson or UtilsJson.readJson5 */ const readJson: (absoluteFilePath: string | string[], defaultValue?: {}, useJson5?: boolean) => any; /** * @deprecated use UtilsJson.readJsonWithComments */ const readJson5: (absoluteFilePath: string | string[], defaultValue?: any) => any; /** * @deprecated use UtilsJson.readJsonWithComments */ const readJsonC: (absoluteFilePath: string | string[], defaultValue?: any) => any; /** * parse json from string * @returns parse json object */ const parse: (jsonInstring: string, useJson5?: boolean) => T | undefined; const replaceLinesInFile: (absoluteFilePath: string | string[], lineReplaceFn: (line: string) => string) => void; /** * @deprecated use UtilsFilesFoldersSync.writeFile * wrapper for fs.writeFileSync */ const writeFile: (absoluteFilePath: string | string[], input: string | object | Buffer, options?: { overrideSameFile?: boolean; preventParentFile?: boolean; }) => boolean; /** * wrapper for fs.writeFileSync */ const writeJson: (absoluteFilePath: string | string[], input: object, optoins?: { preventParentFile?: boolean; writeJson5?: boolean; }) => boolean; const writeJson5: (absoluteFilePath: string | string[], input: object) => boolean; const writeJsonC: (absoluteFilePath: string | string[], input: object) => boolean; /** * return absolute paths for folders inside folders * @returns absoulte pathes to folders from path */ const foldersFrom: (pathToFolder: string | string[], options?: { recursive?: boolean; omitRootFolders?: string[]; omitRootFoldersThatStartWith?: string[]; }) => string[]; /** * @returns absolute pathes to links from path */ const linksToFoldersFrom: (pathToFolder: string | string[], outputRealPath?: boolean) => string[]; /** * @returns absolute paths for folders inside folders */ const linksToFolderFrom: (pathToFolder: string | string[]) => string[]; /** * @deprecated use UtilsFilesFoldersSync.getFilesFrom * return absolute paths for files inside folder or link to folder */ const getFilesFrom: (folderOrLinkToFolder: string | string[], options?: UtilsFilesFoldersSync.UtilsFilesFoldersSyncGetFilesFromOptions) => string[]; /** * @deprecated use UtilsFilesFoldersSync.getFoldersFrom * return absolute paths for folders inside folder or link to folder */ const getFoldersFrom: (folderOrLinkToFolder: string | string[], options?: UtilsFilesFoldersSync.UtilsFilesFoldersSyncGetFilesFromOptions) => string[]; /** * @deprecated use UtilsFilesFoldersSync.filesFrom * return absolute paths for folders inside folders */ const filesFrom: (pathToFolder: string | string[], recrusive?: boolean, incudeUnexistedLinks?: boolean) => string[]; /** * @deprecated use UtilsOs.openFolderInFileExplorer * @param folderPath */ const openFolderInFileExplorer: (folderPath: string) => void; const hideNodeWarnings: () => void; }