@iobroker/create-adapter
Version:
Command line utility to create customized ioBroker adapters
150 lines (149 loc) • 4.99 kB
TypeScript
import type { AxiosRequestConfig } from "axios";
import type { Answers } from "./core/questions";
/**
*
* @param message
*/
export declare function error(message: string): void;
export declare const isWindows: boolean;
/**
* Executes an npm command with update-notifier disabled and common parameters
*
* @param args The npm command arguments
* @param options (optional) Some options for the command execution
*/
export declare function executeNpmCommand(args: string[], options?: Partial<ExecuteCommandOptions>): Promise<ExecuteCommandResult>;
/**
*
*/
export interface ExecuteCommandOptions {
/** Whether the executed command should be logged to the stdout. Default: false */
logCommandExecution: boolean;
/** The directory to execute the command in */
cwd: string;
/** Where to redirect the stdin. Default: process.stdin */
stdin: NodeJS.ReadStream;
/** A write stream to redirect the stdout, "ignore" to ignore it or "pipe" to return it as a string. Default: process.stdout */
stdout: NodeJS.WriteStream | "pipe" | "ignore";
/** A write stream to redirect the stderr, "ignore" to ignore it or "pipe" to return it as a string. Default: process.stderr */
stderr: NodeJS.WriteStream | "pipe" | "ignore";
/** Environment variables for the command */
env: Record<string, string>;
}
/**
*
*/
export interface ExecuteCommandResult {
/** The exit code of the spawned process */
exitCode?: number;
/** The signal the process received before termination */
signal?: string;
/** If options.stdout was set to "buffer", this contains the stdout of the spawned process */
stdout?: string;
/** If options.stderr was set to "buffer", this contains the stderr of the spawned process */
stderr?: string;
}
export declare function executeCommand(command: string, options?: Partial<ExecuteCommandOptions>): Promise<ExecuteCommandResult>;
/**
* Executes a command and returns the exit code and (if requested) the stdout
*
* @param command The command to execute
* @param args The command line arguments for the command
* @param options (optional) Some options for the command execution
*/
export declare function executeCommand(command: string, args: string[], options?: Partial<ExecuteCommandOptions>): Promise<ExecuteCommandResult>;
/**
* Recursively enumerates all files in the given directory
*
* @param dir The directory to scan
* @param predicate An optional predicate to apply to every found file system entry
* @returns A list of all files found
*/
export declare function enumFilesRecursiveSync(dir: string, predicate?: (name: string, parentDir: string) => boolean): string[];
/**
* Recursively copies all files from the source to the target directory
*
* @param sourceDir The directory to scan
* @param targetDir The directory to copy to
* @param predicate An optional predicate to apply to every found file system entry
*/
export declare function copyFilesRecursiveSync(sourceDir: string, targetDir: string, predicate?: (name: string) => boolean): void;
/**
* Adds https proxy options to an axios request if they were defined as an env variable
*
* @param options The options object passed to axios
*/
export declare function applyHttpsProxy(options: AxiosRequestConfig): AxiosRequestConfig;
/**
*
* @param licenseText
* @param answers
*/
export declare function formatLicense(licenseText: string, answers: Answers): string;
/**
*
* @param answers
*/
export declare function getFormattedLicense(answers: Answers): string;
/**
* Replaces 4-space indentation with tabs
*
* @param text
*/
export declare function indentWithTabs(text: string): string;
/**
* Replaces tab indentation with 4 spaces
*
* @param text
*/
export declare function indentWithSpaces(text: string): string;
/**
* Normalizes formatting of a JSON string
*
* @param json
* @param indentation
*/
export declare function formatJsonString(json: string, indentation: "Tab" | "Space (4)"): string;
export declare enum Quotemark {
"single" = "'",
"double" = "\""
}
/**
* Formats a JS source file to use single quotes
*
* @param sourceText
* @param quotes
*/
export declare function jsFixQuotes(sourceText: string, quotes: keyof typeof Quotemark): string;
/**
* Formats a TS source file to use single quotes
*
* @param sourceText
* @param quotes
*/
export declare function tsFixQuotes(sourceText: string, quotes: keyof typeof Quotemark): string;
/**
*
* @param sourceText
* @param answers
* @param extension
*/
export declare function formatWithPrettier(sourceText: string, answers: Pick<Answers, "quotes" | "indentation">, extension: "js" | "ts" | "json"): Promise<string>;
/**
*
*/
export declare function getOwnVersion(): string;
/**
*
* @param name
*/
export declare function capitalize(name: string): string;
/**
*
* @param name
*/
export declare function kebabCaseToUpperCamelCase(name: string): string;
/**
*
*/
export declare function getRequestTimeout(): number;