UNPKG

@lonu/stc

Version:

A tool for converting OpenApi/Swagger/Apifox into code.

113 lines 3.64 kB
import type { ExpandGlobOptions } from "../deps/jsr.io/@std/fs/1.0.18/mod.js"; interface ICopyFileOptions { /** * 覆盖现有文件或目录。默认为 true */ overwrite?: boolean; } /** * 驼峰命名 * @param str - 字符 * @param pascalCase - 是否首字母大写 */ export declare const camelCase: (str: string, pascalCase?: boolean) => string; /** * 首字母小写 * @param str - 字符 */ export declare const lowerCase: (str: string) => string; /** * 首字母大写 * @param str - 字符 */ export declare const upperCase: (str: string) => string; /** * 读取文件 * @param filePath - 文件路径 */ export declare const readFile: (filePath: string) => Promise<string>; /** * 创建文件。如果不存在会被自动创建,存在会被覆盖 * * @param filePath - 文件路径 * @param content - 文件内容 */ export declare const createFile: (filePath: string, content: string, { append, banner }?: { append?: boolean; banner?: boolean; }) => Promise<void>; /** * 将给定的内容写入指定路径的文件中 * * @param {string} filePath - 要创建或覆盖的文件的路径 * @param {ArrayBuffer} content - 要写入文件的内容 * @return {Promise<void>} - 在文件成功写入时解析,或在出现错误时拒绝 */ export declare const createAppFile: (filePath: string, content: ArrayBuffer) => Promise<void>; /** * 覆盖复制文件 * @param from - 复制位置 * @param to - 目标位置 */ export declare const copyFile: (from: string, to: string, options?: ICopyFileOptions) => void; /** * 清空目录 * @param dir - 目录 */ export declare const emptyDirectory: (dir: string) => Promise<void>; /** * ref type * @param ref - ref */ export declare const getRefType: (ref: string) => string; /** * 根据值获取对象的 key * @param obj - 对象 * @param value - 值 */ export declare const getObjectKeyByValue: (obj: Record<string, string>, value: string) => string | undefined; /** * 检查给定的对象是否具有指定的键。 * * @param {Record<string, string>} obj - 要检查键的对象 * @param {string} name - 要检查的键的名称 * @return {boolean} 如果对象具有指定的键,则返回true,否则返回false */ export declare const hasKey: (obj: Record<string, unknown>, name: string) => boolean; /** * Converts a string value to its corresponding JavaScript data type. * * @param {string} value - The value to be converted. * @return {any} The converted JavaScript data type. */ export declare const convertValue: (value: string) => any; /** * Fetches a client from the specified URL with optional request options. * * @param {string} url - The URL to fetch the client from. * @param {RequestInit & { timeout?: number }} options - Optional request options. * @return {Promise<Response>} A promise that resolves to the response from the server. */ export declare const fetchClient: (url: string, options?: RequestInit & { timeout?: number; }) => Promise<import("undici-types").Response>; /** * 移除文件 * @param glob - 匹配文件 * @param options - 选项 */ export declare const removeFile: (glob: string | URL, options?: ExpandGlobOptions) => Promise<void>; /** * 清除文件 banner * @param path - 文件路径 */ export declare const removeFileBanner: (path: string) => Promise<string>; /** * 生成差异文件 * @param source - 源文件 * @param content - 内容 * @param clean - 是否清除差异 */ export declare const createDiffFile: (source: string, content: string, clean?: boolean) => Promise<void>; export {}; //# sourceMappingURL=utils.d.ts.map