UNPKG

@dovenv/utils

Version:
1,799 lines (1,778 loc) 172 kB
import { rgbToHex, rgbToCIELab, rgbToHsl, rgbToXyz, xyzToCIELab, hslToRgb, hexToRgb } from '@vibrant/color'; import chromaJS from 'chroma-js'; import * as _ascii_kit_font from '@ascii-kit/font'; import { Font } from '@ascii-kit/font'; import chalk, { ChalkInstance } from 'chalk'; import { highlight as highlight$1 } from 'cli-highlight'; import { TableConstructorOptions } from 'cli-table3'; export { default as Table, TableConstructorOptions } from 'cli-table3'; import columnify from 'columnify'; import { boxen } from '@visulima/boxen'; import * as fs from 'fs'; import { globby, globbyStream } from 'globby'; import { rename, writeFile as writeFile$1, readFile as readFile$1 } from 'node:fs/promises'; import { LocalStorage } from 'node-localstorage'; import * as o from 'open'; import { TreeContent, TreeConfig } from '@ascii-kit/tree'; import * as json_schema_to_zod from 'json-schema-to-zod'; import { JsonSchema } from 'json-schema-to-zod'; import * as node_modules_zod_v4_core_json_schema_cjs from 'node_modules/zod/v4/core/json-schema.cjs'; import { z as z$1, ZodError } from 'zod/v4'; import * as z from 'zod'; import { ZodType } from 'zod'; import { compile, Options as Options$1 } from 'json-schema-to-typescript-lite'; export { default as supportsHyperlinks } from 'supports-hyperlinks'; import { npmRunPathEnv } from 'npm-run-path'; import { hideBin as hideBin$1 } from 'yargs/helpers'; import { Argv } from 'yargs'; import Enquirer from 'enquirer'; import * as p from '@clack/prompts'; import * as consola from 'consola'; import ora from 'ora'; import { matcher } from 'matcher'; export { qrcode } from '@ascii-kit/qr'; import { JSONSchemaForNPMPackageJsonFiles } from '@schemastore/package'; export { createWriteStream } from 'node:fs'; export { fileURLToPath } from 'node:url'; export { gzip, tar, tgz, zip } from 'compressing'; export { default as process } from 'node:process'; export { default as terminalSize } from 'terminal-size'; export { default as stringWidth } from 'string-width'; import * as nodeEmoji from 'node-emoji'; export { nodeEmoji as emoji }; import { deepmergeCustom } from 'deepmerge-ts'; export { deepmerge, deepmergeCustom } from 'deepmerge-ts'; import * as csv from '@structium/csv'; export { csv }; import * as xml from '@structium/xml'; export { xml }; import * as ini from '@structium/ini'; export { ini }; import * as yaml from '@structium/yaml'; export { yaml }; import * as toml from '@structium/toml'; export { toml }; import * as svg from '@structium/svg'; export { svg }; export { html, markdown } from '@structium/html-markdown'; /** List of figfonts names */ declare const fonts: [ "morse", "jerusalem", "moscow", "katakana", "runic", "smtengwar", "mshebrew210", "ntgreek", "runyc", "1row", "tengwar", "3-d", "tsalagi", "3d-ascii", "3d--diagonal", "4max", "amc--3--liv1", "amc--3--line", "5--line--oblique", "5lineoblique", "amc--razor", "amc--neko", "amc--slash", "amc--thin", "amc--tubes", "amc--slider", "3d_diagonal", "ansi--regular", "ascii--new--roman", "amc--untitled", "alligator", "acrobatic", "ansi--shadow", "alligator2", "avatar", "arrows", "b1ff", "banner3-d", "alphabet", "banner3", "alpha", "banner4", "banner", "basic", "barbwire", "benjamin", "bell", "big--chief", "3d", "big--money-ne", "big--money-se", "big--money-sw", "big--money-nw", "bigfig", "big", "binary", "block", "bright", "bloody", "bolger", "broadway--kb", "catwalk", "calvin--s", "braced", "cards", "blocks", "bulbhead", "broadway", "chiseled", "bubble", "caligraphy", "chunky", "coinstak", "cola", "caligraphy2", "contrast", "computer", "crawford", "crawford2", "colossal", "cosmike", "cursive", "cybermedium", "cyberlarge", "cricket", "cygnet", "cybersmall", "crazy", "decimal", "danc4", "dwhistled", "dos--rebel", "dancing--font", "diamond", "doom", "diet--cola", "delta--corps--priest--1", "dot--matrix", "digital", "double", "dr--pepper", "double--shorts", "efti--chess", "efti--italic", "efti--piti", "def--leppard", "efti--robot", "efti--font", "efti--water", "efti--wall", "elite", "doh", "epic", "filter", "electronic", "fender", "fire--font-k", "fire--font-s", "flower--power", "flipped", "fun--face", "four--tops", "fun--faces", "fuzzy", "ghost", "fraktur", "graceful", "goofy", "ghoulish", "glenyn", "greek", "gradient", "gothic", "graffiti", "georgi16", "heart--left", "horizontal--left", "hieroglyphs", "heart--right", "hollywood", "hex", "horizontal--right", "henry--3d", "invita", "georgia11", "isometric1", "isometric3", "icl-1900", "isometric2", "impossible", "italic", "js--block--letters", "isometric4", "ivrit", "js--bracket--letters", "js--capital--curves", "js--cursive", "amc--razor2", "js--stick--letters", "konto", "amc--aaa01", "jacky", "jazmine", "3x5", "knob", "keyboard", "konto--slant", "letters", "lcd", "larry--3d--2", "linux", "line--blocks", "lockergnome", "maxfour", "larry--3d", "marquee", "lean", "lil--devil", "madrid", "merlin2", "mike", "kban", "merlin1", "morse2", "mirror", "modular", "mini", "muzzle", "nt--greek", "nancyj-fancy", "nancyj-underlined", "nv--script", "nscript", "nancyj", "mnemonic", "nipples", "octal", "nancyj-improved", "o8", "old--banner", "patorjks--cheese", "os2", "pawp", "pepper", "patorjk-hex", "ogre", "puffy", "poison", "peaks--slant", "contessa", "puzzle", "rectangles", "red--phoenix", "pyramid", "roman", "rammstein", "rounded", "relief", "relief2", "reverse", "rotated", "sl--script", "rot13", "rowan--cap", "rozzo", "s--blood", "serifcap", "santa--clara", "slide", "short", "small--caps", "slant", "small--isometric1", "small--slant", "slant--relief", "small--script", "small--poison", "small--shadow", "spliff", "soft", "small--tengwar", "small", "stacey", "stforek", "speed", "stampate", "stampatello", "stick--letters", "star--wars", "stop", "star--strips", "straight", "script", "sub-zero", "stellar", "standard", "test1", "stronger--than--all", "swan", "tanja", "swamp--land", "pebbles", "three--point", "the--edge", "thin", "thick", "term", "ticks", "ticks--slant", "thorned", "tombstone", "tiles", "tinker-toy", "train", "tubes-smushed", "bear", "tubular", "two--point", "usa--flag", "weird", "varsity", "wow", "twisted", "wavy", "univers", "wet--letter", "amc3line", "amc3liv1", "alligator3", "amcrazo2", "amcaaa01", "amcslder", "amcneko", "amcun1", "amcslash", "ascii_new_roman", "amcrazor", "broadway_kb", "amcthin", "amctubes", "cosmic", "bigchief", "dietcola", "dancingfont", "calgphy2", "drpepper", "doubleshorts", "dotmatrix", "eftipiti", "eftichess", "eftifont", "eftiwall", "eftitalic", "funface", "eftiwater", "fire_font-k", "eftirobot", "fourtops", "dosrebel", "flowerpower", "fire_font-s", "heart_right", "horizontalleft", "halfiwi", "funfaces", "koholint", "horizontalright", "larry3d", "kontoslant", "maxiwi", "lineblocks", "heart_left", "miniwi", "kompaktblk", "red_phoenix", "defleppard", "rowancap", "oldbanner", "rev", "lildevil", "santaclara", "sblood", "peaksslant", "smscript", "s-relief", "slscript", "smkeyboard", "smpoison", "smshadow", "smisome1", "six-fo", "starwars", "threepoint", "smslant", "starstrips", "twopoint", "ticksslant", "swampland", "wetletter", "sweet", "ublk", "shimrod", "usaflag", "tubes-regular", "whimsy", "smallcaps", "peaks", "small--keyboard", "stencil", "l4me", "nvscript", "5x8", "brite", "6x9", "5x7", "chartr", "briteb", "6x10", "britebi", "chartri", "britei", "clb6x10", "clb8x10", "cli8x8", "clb8x8", "clr4x6", "clr6x6", "clr5x6", "clr5x8", "clr6x10", "clr6x8", "clr5x10", "clr7x8", "clr8x10", "clr7x10", "courbi", "clr8x8", "courb", "couri", "cour", "helv", "helvb", "helvi", "sansb", "sansbi", "sans", "sbook", "sbookbi", "sansi", "times", "sbookb", "sbooki", "tty", "ttyb", "xbrite", "helvbi", "utopia", "utopiab", "utopiai", "xbritei", "xchartr", "xbritebi", "utopiabi", "xbriteb", "xchartri", "xhelvb", "xcourb", "xhelv", "xcourbi", "xcour", "xsbookbi", "xsansi", "xhelvbi", "xsansb", "trek", "xsbookb", "64f1____", "xcouri", "xsbooki", "xttyb", "xtimes", "4x4_offr", "advenger", "1943____", "aquaplan", "a_zooloo", "xsbook", "atc_gran", "this", "assalt_m", "atc_____", "asc_____", "battle_s", "b_m__200", "baz__bil", "c_ascii_", "c1______", "beer_pub", "shadow", "c_consen", "bubble__", "c2______", "bubble_b", "char3___", "caus_in_", "charact1", "char1___", "charact2", "charact4", "char4___", "char2___", "charact5", "charact6", "characte", "coil_cop", "charact3", "charset_", "d_dragon", "com_sen_", "dcs_bfmo", "convoy__", "demo_m__", "deep_str", "druid___", "devilish", "demo_2__", "demo_1__", "e__fist_", "eca_____", "ebbs_2__", "fair_mea", "faces_of", "fbr1____", "fairligh", "f15_____", "fbr2____", "fantasy_", "fbr_stri", "fbr_tilt", "flyn_sh", "fbr12___", "fp1_____", "finalass", "future_3", "funky_dr", "fireing_", "future_1", "fp2_____", "future_5", "future_2", "future_6", "future_4", "future_7", "grand_pr", "future_8", "gauntlet", "ghost_bo", "battlesh", "gothic__", "heroboti", "hills___", "green_be", "hades___", "house_of", "hypa_bal", "high_noo", "heavy_me", "henry3d", "italics_", "home_pak", "hyper___", "inc_raw_", "kgames_i", "krak_out", "kik_star", "lazy_jon", "letter_w", "lexible_", "master_o", "letterw3", "mad_nurs", "magic_ma", "joust___", "modern__", "mig_ally", "nfi1____", "npn_____", "mayhem_d", "outrun__", "mcg_____", "odel_lak", "notie_ca", "pacos_pe", "ok_beer_", "p_s_h_m_", "panther_", "platoon_", "platoon2", "pod_____", "xsansbi", "phonix__", "rally_s2", "rainbow_", "pawn_ins", "r2-d2___", "radical_", "xhelvi", "raw_recu", "rally_sp", "rampage_", "rastan__", "road_rai", "rok_____", "skateord", "rockbox_", "skate_ro", "roman___", "skateroc", "script__", "ripper_", "sketch_s", "sm______", "spc_demo", "stencil1", "stealth_", "street_s", "stencil2", "super_te", "subteran", "space_op", "star_war", "tec_7000", "tec1____", "taxi____", "tecrvs__", "top_duck", "tav1____", "timesofl", "ti_pan__", "trashman", "tomahawk", "tsn_base", "twin_cob", "tsm_____", "triad_st", "ucf_fan_", "unarmed_", "ts1_____", "xsans", "type_set", "ugalympi", "usa_____", "xtty", "asslt__m", "war_of_w", "vortron_", "usa_pq__", "yie_ar_k", "z-pilot_", "yie-ar__", "zig_zag_", "zone7___", "etcrvs__", "p_skateb", "ascii___", "t__of_ap", "rad_phan", "ebbs_1__", "rad_____", "new_asci", "rci_____" ]; /** * Any Array type * Same as `any[]` type. Used only for prevent ts errors. */ type AnyArray = any[]; /** * Any type * Same as `any` type. Used only for prevent ts errors. */ type Any = any; /** * Values of Object. */ type ObjectValues<Values> = Values[keyof Values]; /** * Keys of Object. */ type ObjectKeys<Values> = keyof Values; /** * DeepPartial. */ type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]>; } : T; /** * Prettify your type for better readability. */ type Prettify<T> = { [K in keyof T]: T[K]; } & {}; /** * NonUndefined. * * @description Exclude undefined from set `A`. * @example * // Expect: "string | null" * SymmetricDifference<string | null | undefined>; */ type NonUndefined<A> = A extends undefined ? never : A; /** * FunctionKeys. * * @description Get union type of keys that are functions in object type `T`. * @example * type MixedProps = {name: string; setName: (name: string) => void; someKeys?: string; someFn?: (...args: any) => any;}; * * // Expect: "setName | someFn" * type Keys = FunctionKeys<MixedProps>; */ type FunctionKeys<T extends object> = { [K in keyof T]-?: NonUndefined<T[K]> extends Function ? K : never; }[keyof T]; /** * NonFunctionKeys. * * @description Get union type of keys that are non-functions in object type `T`. * @example * type MixedProps = {name: string; setName: (name: string) => void; someKeys?: string; someFn?: (...args: any) => any;}; * * // Expect: "name | someKey" * type Keys = NonFunctionKeys<MixedProps>; */ type NonFunctionKeys<T extends object> = { [K in keyof T]-?: NonUndefined<T[K]> extends Function ? never : K; }[keyof T]; /** * AssertEqual. * * @description Checks if two types `T` and `U` are equal. * @example * type Test = AssertEqual<string, string>; // Expected: true * type TestFail = AssertEqual<string, number>; // Expected: false */ type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends (<V>() => V extends U ? 1 : 2) ? true : false; /** * ExpectEqual. * * @description Returns the type `T` if `T` and `U` are equal; otherwise, returns `never`. * @example * type Test = ExpectEqual<string, string>; // Expected: string * type TestFail = ExpectEqual<string, number>; // Expected: never */ type ExpectEqual<T, U> = AssertEqual<T, U> extends true ? T : never; /** * DeepNonNullable. * * @description NonNullable that works for deeply nested structure. * @example * type NestedProps = { * first?: null | { * second?: null | { * name?: string | null | * undefined; * }; * }; * }; * type RequiredNestedProps = DeepNonNullable<NestedProps>; * // Expect: { * // first: { * // second: { * // name: string; * // }; * // }; * // } */ type DeepNonNullable<T> = Prettify<_DeepNonNullable<T>>; type _DeepNonNullable<T> = T extends (...args: AnyArray) => Any ? T : T extends AnyArray ? Prettify<Array<_DeepNonNullable<NonNullable<T[number]>>>> : T extends object ? Prettify<{ [P in keyof T]-?: _DeepNonNullable<NonNullable<T[P]>>; }> : Prettify<NonNullable<T>>; type ReturnAwaitedType<T extends (...args: Any) => Any> = Awaited<ReturnType<T>>; /** * DeepRequired. * * @description Required that works for deeply nested structure. * @example * type NestedProps = { * first?: { * second?: { * name?: string; * }; * }; * }; * type RequiredNestedProps = DeepRequired<NestedProps> * // Expect: { * // first: { * // second: { * // name: string; * // }; * // }; * // } */ type DeepRequired<T> = Prettify<_DeepRequired<T>>; type _DeepRequired<T> = T extends (...args: AnyArray) => Any ? T : T extends AnyArray ? Prettify<_DeepRequiredArray<T[number]>> : T extends object ? Prettify<_DeepRequiredObject<T>> : T; type _DeepRequiredArray<T> = Array<_DeepRequired<NonUndefined<T>>>; type _DeepRequiredObject<T> = { [P in keyof T]-?: _DeepRequired<NonUndefined<T[P]>>; }; type PackageJSON = Prettify<JSONSchemaForNPMPackageJsonFiles & { /** * The devEngines field aids engineers working on a codebase to all be using the same tooling. * * @see https://docs.npmjs.com/cli/v11/configuring-npm/package-json#devengines */ devEngines?: { [key in 'cpu' | 'os' | 'libc' | 'runtime' | 'packageManager']?: { name: string; version?: string; onFail?: 'warn' | 'error' | 'ignore'; }; }; }>; type Color$1 = typeof chalk; type HighlightOpts = Parameters<typeof highlight$1>[1]; type FontName = typeof fonts[number]; type FontOptions = NonNullable<Parameters<Font['text']>[1]>; type GradientColors = string[] | { color: string; pos: number; }[]; type GradientOpts = { /** The gradient can be generated using RGB or HSV interpolation. HSV usually produces brighter colors. Interpolation can be set to rgb for RGB interpolation, orhsv for HSV interpolation. Defaults to rgb. Case insentitive. */ interpolation?: 'rgb' | 'hsv'; /** Used only in the case of HSV interpolation. Because hue can be considered as a circle, there are two ways to go from a color to another color. HsvSpin can be either short or long, depending on if you want to take the shortest or the longest way between two colors. Defaults to short. Case insensitive. */ hsvSpin?: 'short' | 'long'; }; declare const chroma: typeof chromaJS; declare const colorConversion: { rgb2hex: typeof rgbToHex; rgb2CIELab: typeof rgbToCIELab; rgb2sl: typeof rgbToHsl; rgb2xyz: typeof rgbToXyz; xyz2CIELab: typeof xyzToCIELab; hslToRgb: typeof hslToRgb; hex2rgb: typeof hexToRgb; }; /** * Highlights the given code using CLI highlighting. * * @param {string} code - The code to highlight. * @param {HighlightOpts} [opts] - Optional options for highlighting. * @param {string} [opts.language] - The language of the code to highlight. Defaults to 'auto'. * @param {string} [opts.theme] - The theme to use for highlighting. Defaults to 'github'. * @returns {string} - The highlighted code. * @example * const code = ` * function greet(name) { * return 'Hello, ' + name + '!'; * } * console.log(greet('World')); * `; * * const highlightedCode = highlight(code, { language: 'javascript' }); * console.log(highlightedCode); */ declare const highlight: (code: string, opts?: HighlightOpts) => string; /** * Provides colors for terminal output. * * @type {object} * @example * console.log(color.green('This text is green')); */ declare const color: Color$1; /** * Generates a gradient string with the specified colors. * * @param {string} txt - The text to apply the gradient to. * @param {GradientColors} colors - An array of color names or hex values. * @param {GradientOpts} [opts] - Custom opts. * @returns {string} - The text with the applied gradient. * @example * // Example usage: * const gradientText = gradient('Gradient Text', ['red', 'yellow', 'green']); * console.log(gradientText); */ declare const gradient: (txt: string, colors: GradientColors, opts?: GradientOpts) => string; type LazyLoaderOptions = { /** * Option to enable debug logging for loading time */ debug?: boolean; }; declare class LazyLoader<O extends Record<string, () => Promise<unknown>>> { #private; private resources; options: LazyLoaderOptions; constructor(resources: O, options?: LazyLoaderOptions); /** * Retrieves a resource by its key, loading it if necessary and caching the result. * * @param {keyof O} key - The key of the resource to load. * @returns {Promise<Awaited<ReturnType<O[K]>>>} The loaded resource. */ get<K extends keyof O>(key: K): Promise<Awaited<ReturnType<O[K]>>>; } declare const _styledeps: LazyLoader<{ font: () => Promise<typeof _ascii_kit_font.Font>; }>; /** * Unicode symbols with fallbacks for older terminals. * * @see https://github.com/sindresorhus/figures/blob/main/index.js * @example * console.log( * icon.warning, * icon.cross, * icon.arrowDown, * icon.bullet * ) */ declare const icon: { readonly tick: string; readonly info: string; readonly warning: string; readonly cross: string; readonly square: string; readonly squareSmall: string; readonly squareSmallFilled: string; readonly squareDarkShade: string; readonly squareMediumShade: string; readonly squareLightShade: string; readonly squareTop: string; readonly squareBottom: string; readonly squareLeft: string; readonly squareRight: string; readonly squareCenter: string; readonly circle: string; readonly circleFilled: string; readonly circleDotted: string; readonly circleDouble: string; readonly circleCircle: string; readonly circleCross: string; readonly circlePipe: string; readonly circleQuestionMark: string; readonly radioOn: string; readonly radioOff: string; readonly checkboxOn: string; readonly checkboxOff: string; readonly checkboxCircleOn: string; readonly checkboxCircleOff: string; readonly questionMarkPrefix: string; readonly bullet: string; readonly dot: string; readonly ellipsis: string; readonly pointer: string; readonly pointerSmall: string; readonly triangleUp: string; readonly triangleUpSmall: string; readonly triangleUpOutline: string; readonly triangleDown: string; readonly triangleDownSmall: string; readonly triangleLeft: string; readonly triangleLeftSmall: string; readonly triangleRight: string; readonly triangleRightSmall: string; readonly lozenge: string; readonly lozengeOutline: string; readonly home: string; readonly hamburger: string; readonly smiley: string; readonly mustache: string; readonly heart: string; readonly star: string; readonly play: string; readonly musicNote: string; readonly musicNoteBeamed: string; readonly nodejs: string; readonly arrowUp: string; readonly arrowDown: string; readonly arrowLeft: string; readonly arrowRight: string; readonly arrowLeftRight: string; readonly arrowUpDown: string; readonly almostEqual: string; readonly notEqual: string; readonly lessOrEqual: string; readonly greaterOrEqual: string; readonly identical: string; readonly infinity: string; readonly subscriptZero: string; readonly subscriptOne: string; readonly subscriptTwo: string; readonly subscriptThree: string; readonly subscriptFour: string; readonly subscriptFive: string; readonly subscriptSix: string; readonly subscriptSeven: string; readonly subscriptEight: string; readonly subscriptNine: string; readonly oneHalf: string; readonly oneThird: string; readonly oneQuarter: string; readonly oneFifth: string; readonly oneSixth: string; readonly oneSeventh: string; readonly oneEighth: string; readonly oneNinth: string; readonly oneTenth: string; readonly twoThirds: string; readonly twoFifths: string; readonly threeQuarters: string; readonly threeFifths: string; readonly threeEighths: string; readonly fourFifths: string; readonly fiveSixths: string; readonly fiveEighths: string; readonly sevenEighth: string; readonly line: string; readonly lineBold: string; readonly lineDouble: string; readonly lineDashed0: string; readonly lineDashed1: string; readonly lineDashed2: string; readonly lineDashed3: string; readonly lineDashed4: string; readonly lineDashed5: string; readonly lineDashed6: string; readonly lineDashed7: string; readonly lineDashed8: string; readonly lineDashed9: string; readonly lineDashed10: string; readonly lineDashed11: string; readonly lineDashed12: string; readonly lineDashed13: string; readonly lineDashed14: string; readonly lineDashed15: string; readonly lineVertical: string; readonly lineVerticalBold: string; readonly lineVerticalDouble: string; readonly lineVerticalDashed0: string; readonly lineVerticalDashed1: string; readonly lineVerticalDashed2: string; readonly lineVerticalDashed3: string; readonly lineVerticalDashed4: string; readonly lineVerticalDashed5: string; readonly lineVerticalDashed6: string; readonly lineVerticalDashed7: string; readonly lineVerticalDashed8: string; readonly lineVerticalDashed9: string; readonly lineVerticalDashed10: string; readonly lineVerticalDashed11: string; readonly lineDownLeft: string; readonly lineDownLeftArc: string; readonly lineDownBoldLeftBold: string; readonly lineDownBoldLeft: string; readonly lineDownLeftBold: string; readonly lineDownDoubleLeftDouble: string; readonly lineDownDoubleLeft: string; readonly lineDownLeftDouble: string; readonly lineDownRight: string; readonly lineDownRightArc: string; readonly lineDownBoldRightBold: string; readonly lineDownBoldRight: string; readonly lineDownRightBold: string; readonly lineDownDoubleRightDouble: string; readonly lineDownDoubleRight: string; readonly lineDownRightDouble: string; readonly lineUpLeft: string; readonly lineUpLeftArc: string; readonly lineUpBoldLeftBold: string; readonly lineUpBoldLeft: string; readonly lineUpLeftBold: string; readonly lineUpDoubleLeftDouble: string; readonly lineUpDoubleLeft: string; readonly lineUpLeftDouble: string; readonly lineUpRight: string; readonly lineUpRightArc: string; readonly lineUpBoldRightBold: string; readonly lineUpBoldRight: string; readonly lineUpRightBold: string; readonly lineUpDoubleRightDouble: string; readonly lineUpDoubleRight: string; readonly lineUpRightDouble: string; readonly lineUpDownLeft: string; readonly lineUpBoldDownBoldLeftBold: string; readonly lineUpBoldDownBoldLeft: string; readonly lineUpDownLeftBold: string; readonly lineUpBoldDownLeftBold: string; readonly lineUpDownBoldLeftBold: string; readonly lineUpDownBoldLeft: string; readonly lineUpBoldDownLeft: string; readonly lineUpDoubleDownDoubleLeftDouble: string; readonly lineUpDoubleDownDoubleLeft: string; readonly lineUpDownLeftDouble: string; readonly lineUpDownRight: string; readonly lineUpBoldDownBoldRightBold: string; readonly lineUpBoldDownBoldRight: string; readonly lineUpDownRightBold: string; readonly lineUpBoldDownRightBold: string; readonly lineUpDownBoldRightBold: string; readonly lineUpDownBoldRight: string; readonly lineUpBoldDownRight: string; readonly lineUpDoubleDownDoubleRightDouble: string; readonly lineUpDoubleDownDoubleRight: string; readonly lineUpDownRightDouble: string; readonly lineDownLeftRight: string; readonly lineDownBoldLeftBoldRightBold: string; readonly lineDownLeftBoldRightBold: string; readonly lineDownBoldLeftRight: string; readonly lineDownBoldLeftBoldRight: string; readonly lineDownBoldLeftRightBold: string; readonly lineDownLeftRightBold: string; readonly lineDownLeftBoldRight: string; readonly lineDownDoubleLeftDoubleRightDouble: string; readonly lineDownDoubleLeftRight: string; readonly lineDownLeftDoubleRightDouble: string; readonly lineUpLeftRight: string; readonly lineUpBoldLeftBoldRightBold: string; readonly lineUpLeftBoldRightBold: string; readonly lineUpBoldLeftRight: string; readonly lineUpBoldLeftBoldRight: string; readonly lineUpBoldLeftRightBold: string; readonly lineUpLeftRightBold: string; readonly lineUpLeftBoldRight: string; readonly lineUpDoubleLeftDoubleRightDouble: string; readonly lineUpDoubleLeftRight: string; readonly lineUpLeftDoubleRightDouble: string; readonly lineUpDownLeftRight: string; readonly lineUpBoldDownBoldLeftBoldRightBold: string; readonly lineUpDownBoldLeftBoldRightBold: string; readonly lineUpBoldDownLeftBoldRightBold: string; readonly lineUpBoldDownBoldLeftRightBold: string; readonly lineUpBoldDownBoldLeftBoldRight: string; readonly lineUpBoldDownLeftRight: string; readonly lineUpDownBoldLeftRight: string; readonly lineUpDownLeftBoldRight: string; readonly lineUpDownLeftRightBold: string; readonly lineUpBoldDownBoldLeftRight: string; readonly lineUpDownLeftBoldRightBold: string; readonly lineUpBoldDownLeftBoldRight: string; readonly lineUpBoldDownLeftRightBold: string; readonly lineUpDownBoldLeftBoldRight: string; readonly lineUpDownBoldLeftRightBold: string; readonly lineUpDoubleDownDoubleLeftDoubleRightDouble: string; readonly lineUpDoubleDownDoubleLeftRight: string; readonly lineUpDownLeftDoubleRightDouble: string; readonly lineCross: string; readonly lineBackslash: string; readonly lineSlash: string; }; /** * Generates ASCII art text using the specified font. * * @param {string} txt - The text to render as ASCII art. * @param {string} fontData - The font to use for rendering. Defaults to 'Standard'. * @param {FontOptions} [opts] - Optional parameters for font rendering. * @returns { Promise<string>} - The ASCII art text. * @example * import font_three_d from '@ascii-kit/font-3d'; * const asciiText = await renderAsciiFont('Hello, World!', font_three_d); * console.log(asciiText); */ declare const renderAsciiFont: (txt: string, fontData: string, opts?: FontOptions) => Promise<string>; /** * Fetches and generates ASCII art text using the specified font name. * * @param {string} txt - The text to render as ASCII art. * @param {FontName} fontName - The name of the font to use for rendering. * @param {FontOptions} [opts] - Optional parameters for font rendering. * @returns {Promise<string>} - The ASCII art text. * @example * const asciiText = await asciiFont('Hello, World!', '3-d'); * console.log(asciiText); */ declare const asciiFont: (txt: string, fontName: FontName, opts?: FontOptions) => Promise<string>; /** * Creates a clickable hyperlink in the terminal, if supported. * If terminal doesn't support clickable links, returns the URL string. * * @param {string} text - The text to display as the link. * @param {string} url - The URL to link to. * @returns {string} - The clickable hyperlink or URL string. * @example * const linkedText = link('Visit Clippo docs', 'https://clippo.pigeonposse.com'); * console.log(linkedText); */ declare const link$1: (text: string, url: string) => string; type TableData = string[][]; type TableOpts = TableConstructorOptions; type ColumnOpts = columnify.GlobalOptions; type ColumnData = Record<string, unknown> | Record<string, unknown>[]; /** * Generates a text-based table from the provided data array. * * @param {TableData} data - The data to display in the table. * @param {TableOpts} [options] - Optional configuration options for the table. * @returns {string} - The text-based table. * @see https://www.npmjs.com/package/table * @example * const data = [ * ['Name', 'Age', 'Country'], * ['John', 30, 'USA'], * ['Alice', 25, 'UK'], * ['Bob', 35, 'Canada'], * ]; * const tableText = table(data); * console.log(tableText); */ declare const table: (data: TableData, options?: TableConstructorOptions) => string; /** * Formats data into aligned columns for better readability. * * @param {ColumnData} data - The data to format into columns. * @param {ColumnOpts} [options] - Optional configuration options for column formatting. * @returns {string} - The text with the data formatted into columns. * @see https://www.npmjs.com/package/columnify * @example * // data for columns * const data = [ * { * name: 'mod1', * description: 'some description which happens to be far larger than the max', * version: '0.0.1', * }, * { * name: 'module-two', * description: 'another description larger than the max', * version: '0.2.0', * } * ]; * * // set columns with custom config * const columnText = columns(data, { * showHeaders: false, * minWidth: 20, * config: { * description: { * maxWidth: 30 * } * } * }); * * // print columns * console.log(columnText); */ declare const columns: <Data extends ColumnData>(data: Data, options?: ColumnOpts) => string; type BoxOptions = NonNullable<Parameters<typeof boxen>[1]>; /** * Creates a styled box around the provided text. * * @param {string} text - The text to display inside the box. * @param {BoxOptions} [options] - Optional configuration options for the box. * @returns {string} - The text with the styled box around it. * @see https://www.npmjs.com/package/boxen * @example * const boxedText = box('This is a boxed text', { padding: 1 }); * console.log(boxedText); */ declare const box: (text: string, options?: BoxOptions) => string; type LineAlign = 'left' | 'center' | 'right'; type TitleAlign = `${LineAlign}` | `top-${LineAlign}` | `bottom-${LineAlign}`; type Color = NonNullable<Parameters<typeof box>[1]>['borderColor']; type LineProps = { title?: string; lineChar?: string; lineColor?: Color; lineDim?: boolean; align?: LineAlign; titleAlign?: TitleAlign; width?: number; }; /** * Generates a line with a title and customizable alignment for both the title and line. * * @param {LineProps} props - Options object. * @returns {string} Formatted line. * @throws {Error} If `width` is not between 1 and 100. */ declare const line: (props?: LineProps) => string; /** * Resolves a sequence of paths or path segments into an absolute path. * * @example * resolvePath('foo', 'bar') // '/absolute/path/foo/bar' */ declare const resolvePath: (...paths: string[]) => string; /** * Determines the relative path from one location to another. * * @example * relativePath('/data/source', '/data/source/project') // 'project' */ declare const relativePath: (from: string, to: string) => string; /** * Returns the file extension of a path. * * @example * getExtName('file.txt') // '.txt' */ declare const getExtName: (path: string) => string; /** * Returns the directory name of a path. * * @example * getDirName('/path/to/file.txt') // '/path/to' */ declare const getDirName: (path: string) => string; /** * Returns the last portion of a path. * * @example * getBaseName('/path/file.txt') // 'file.txt' * getBaseName('/path/file.txt', '.txt') // 'file' */ declare const getBaseName: (path: string, suffix?: string) => string; /** * Determines whether a path is absolute. * * @example * isAbsolutePath('/usr/bin') // true * isAbsolutePath('file.txt') // false */ declare const isAbsolutePath: (path: string) => boolean; /** * Normalizes a path, resolving '..', '.', and redundant separators. * * @example * normalizePath('foo//bar/../baz') // 'foo/baz' */ declare const normalizePath: (path: string) => string; /** * Renames (moves) a file or directory asynchronously. * * @param {string} oldPath - The current name or path of the file/directory. * @param {string} newPath - The new name or path for the file/directory. * @returns {Promise<void>} Resolves when the operation is complete. * @example * await renamePath('./old-name.txt', './new-name.txt') */ declare const renamePath: typeof rename; declare const writeFile: typeof writeFile$1; /** * Find files and directories using glob patterns. * * @example const paths = await getPaths(['*', '!src']); * console.log(paths); * //=> ['pigeon', 'rainbow'] */ declare const getPaths: typeof globby; /** * Find files and directories using glob patterns. * * @example * for await (const path of getPathsStream('*.tmp')) { * console.log(paths); * } */ declare const getPathsStream: typeof globbyStream; /** * Checks if two file paths are equal after normalization. * Normalization ensures that differences like trailing slashes or redundant path segments are ignored. * * ---. * * @param {string} path1 - The first file path to compare. * @param {string} path2 - The second file path to compare. * @returns {boolean} `true` if the paths are equal, `false` otherwise. */ declare const arePathsEqual: (path1: string, path2: string) => boolean; /** * Converts a file path to a file URL. * * @param {string} input - The file path to convert. * @returns {string} The file URL. * @example * const fileUrl = path2FileUrl('./path/to/file') * console.log(fileUrl) * //=> 'file:///path/to/file' */ declare const path2FileUrl: (input: string) => string; /** * Check if a string is a valid path. * * @param {string} str - The string to test. * @returns {boolean} True if the string is a valid path. * @example * isPath('..') // true * isPath('foo bar') // false * isPath('C:\\') // true * isPath('foo\\bar') // true * isPath('foo/bar') // true * isPath('foo bar/baz') // false */ declare const isPath: (str: string) => boolean; /** * Creates a directory if it does not exist. * * @param {string} path - Path to the directory to create. * @returns {Promise<void>} - A promise that resolves when the directory has been created. * @example * await ensureDir('./path/to/directory') */ declare const ensureDir: (path: string) => Promise<void>; /** * Reads the contents of a directory. * * @param {string} path - Path to the directory to read. * @returns {Promise<import('node:fs').Dirent[]>} - A promise that resolves to an array of {@link https://nodejs.org/api/fs.html#class-fs-dirent | fs.Dirent} objects. * @example * const dirItems = await readDir('./path/to/directory') */ declare const readDir: (path: string) => Promise<fs.Dirent<string>[]>; /** * Gets the file names in a directory and filters them by extension. * * @param {object} props - Function props. * @param {string} props.path - Path to the directory. * @param {string[]} props.extensions - Array of extensions to filter by, e.g., ['.md', '.txt']. * @returns {Promise<string[]>} - A promise that resolves with an array of file names without extensions. */ declare function getFilteredFileNames({ path, extensions, }: { path: string; extensions: string[]; }): Promise<string[]>; /** * Gets the current directory. * * @param {string} [path] - An optional path to resolve the directory from. * @returns {string} - The current directory. * @example getCurrentDir() */ declare const getCurrentDir: (path?: string) => string; /** * Joins path segments. * * @param {...string} paths - Path segments to join. * @returns {string} - The joined path. * @example joinPath('user', 'pigeonposse') */ declare function joinPath(...paths: string[]): string; /** * Resolves path segments into an absolute path. * * @param {...string} paths - Path segments to resolve. * @returns {string} - The resolved absolute path. */ declare const getAbsolutePath: (...paths: string[]) => string; /** * Validates and resolves a path with home directory replacement. * * @param {string} path - The path to validate and resolve. * @returns {string} - The validated and resolved absolute path. * @example * import { validateHomeDir } from '@dovenv/utils' * * const path = validateHomeDir('~/Documents') * * console.log(path) // returns: /users/{username}/Documents * * const path = validateHomeDir('/Home') * * console.log(path) // returns same: /Home */ declare function validateHomeDir(path: string): string; /** * Reads the content of a file at the specified path. * * @param {string} path - The path of the file to read. * @returns {Promise<string | Buffer>} - A promise that resolves to the content of the file as a string or buffer. * @throws {Error} If an error occurs while reading the file. * @example import { readFile } from '@dovenv/utils' * * try { * const content = await readFile('./example.txt'); * console.log(content); * } catch (error) { * console.error('Error reading file:', error); * } */ declare const readFile: typeof readFile$1; /** * Reads multiple files based on specified glob patterns and returns their contents. * * @param {Parameters<typeof getPaths>[0]} patterns - The glob patterns to match file paths. * @param {object} [opts] - Optional configurations. * @param {Parameters<typeof getPaths>[1]} [opts.inputOpts] - Optional options for glob pattern matching. * @param {object} [opts.hook] - Optional hooks for handling file data. * @param {Function} [opts.hook.onFile] - A callback function invoked for each file's path and content. * @returns {Promise<{ path: string, content: string }[]>} - A promise that resolves to an array of objects containing file paths and their contents. * @throws {Error} If an error occurs while reading any file. */ declare const readFiles: (patterns: Parameters<typeof getPaths>[0], opts?: { inputOpts?: Parameters<typeof getPaths>[1]; hook?: { onFile?: (data: { path: string; content: string; }) => void | Promise<void>; }; }) => Promise<{ path: string; content: string; }[]>; /** * Removes a directory and its contents if it exists. * * @param {string} path - The path of the directory to remove. * @throws {Error} If an error occurs while removing the directory. * @example import { removeDir } from '@dovenv/utils' * * try { * await removeDir('./my/path') * } catch (e) { * console.log(e) * } */ declare function removeDir(path: string): Promise<void>; /** * Removes a directory and its contents if it exists. * * @param {string} path - The path of the directory to remove. * @throws {Error} If an error occurs while removing the directory. * @example import { removeDirIfExist } from '@dovenv/utils' * * await removeDirIfExist('./my/path') */ declare function removeDirIfExist(path: string): Promise<void>; /** * Removes a file or directory if it exists. * * @param {string} path - The path of the file or directory to remove. * @throws {Error} If an error occurs while removing the file or directory. * @example * try { * await removePathIfExist('./my/path') * } catch (e) { * console.log(e) * } */ declare function removePathIfExist(path: string): Promise<void>; /** * Removes a file if it exists. * * @param {string} path - The path of the file to remove. * @throws {Error} If an error occurs while removing the file. * @example * try { * await removeFile('./my/path') * } catch (e) { * console.log(e) * } */ declare function removeFileIfExist(path: string): Promise<void>; /** * Removes a file. * * @param {string} path - The path of the file to remove. * @throws {Error} If an error occurs while removing the file. * @example * try { * await removeFile('./my/path') * } catch (e) { * console.log(e) * } */ declare function removeFile(path: string): Promise<void>; /** * Checks if the given path points to a directory. * * @param {string} path - The path to check. * @returns {Promise<boolean>} - A promise that resolves to true if the path points to a directory, otherwise false. * @example import { isDirectory } from '@dovenv/utils' * * const isDir = await isDirectory('./my/path') */ declare function isDirectory(path: string): Promise<boolean>; /** * Creates a directory at the specified path. * * @param {string} path - The path of the directory to create. * @throws {Error} If an error occurs while creating the directory. * @example import { createDir } from '@dovenv/utils' * await createDir('./my/dir') */ declare function createDir(path: string): Promise<void>; /** * Checks if a directory exists at the specified path. * * @param {string} path - The path to check. * @returns {Promise<boolean>} - A promise that resolves to true if a directory exists at the specified path, otherwise false. * @example import { existsDir } from '@dovenv/utils' * const exist = await existsDir('./my/dir') */ declare function existsDir(path: string): Promise<boolean>; /** * Checks if a file exists at the specified path. * * @param {string} path - The path to the file. * @returns {Promise<boolean>} - A promise that resolves to true if the file exists, otherwise false. * @throws {Error} If an error occurs while checking the existence of the file. * @example import { existsFile } from '@dovenv/utils' * * const existPKG = await existsFile('./package.json') */ declare function existsFile(path: string): Promise<boolean>; /** * Writes content to a file at the specified path. * * @param {string} path - The path of the file to write to. * @param {string | Buffer} content - The content to write to the file. * @throws {Error} If an error occurs while writing to the file. * @example import { writeFileContent } from '@dovenv/utils' * * await writeFileContent('./greetFile.txt', 'Hello') */ declare function writeFileContent(path: string, content: string | Buffer): Promise<void>; /** * Checks if a file or directory exists at the specified path. * * @param {string} path - The path to check. * @returns {Promise<boolean>} - A promise that resolves to true if a file or directory exists at the specified path, otherwise false. * @throws {Error} If an error occurs while checking the existence of the path. * @example import { existsPath } from '@dovenv/utils' * * const existPKG = await existsPath('./package.json') */ declare function existsPath(path: string): Promise<boolean>; /** * Copy a file from input path to output path. * * @param {{input: string, output: string}} options - Options object with input and output paths. * @returns {Promise<void>} - Resolves when the file has been copied. * @throws {Error} If there is an error copying the file. * @example import { copyFile } from '@dovenv/utils' * * const copyResult = await copyFile({ * input : '/path/to/source.txt', * output: '/path/to/destination.txt', * }) */ declare const copyFile: ({ input, output, }: { input: string; output: string; }) => Promise<void>; /** * Copy a directory from input path to output path. * * @param {{input: string, output: string}} options - Options object with input and output paths. * @returns {Promise<void>} - Resolves when the directory has been copied. * @throws {Error} If there is an error copying the directory. * @example * * const copyResult = await copyDir({ * input : '/path/to/sourceDir', * output: '/path/to/destinationDir', * }) */ declare const copyDir: ({ input, output, }: { input: string; output: string; }) => Promise<void>; /** * Creates a symbolic link from the input path to the output path. * * @param {{input: string, output: string}} options - Options object with input and output paths. * @returns {Promise<void>} - Resolves when the symbolic link has been created. * @throws {Error} If there is an error creating the symbolic link. * @example import { createSymlink } from '@dovenv/utils' * * const symlinkResult = await createSymlink({ * input : '/path/to/source', * output: '/path/to/destination', * }) */ declare const createSymlink: ({ input, output, }: { input: string; output: string; }) => Promise<void>; /** * Creates a new instance of LocalStorage with the specified location. * * @param {string} location - The location where the local storage data will be stored. * @returns {LocalStorage} - A new instance of LocalStorage. * @example import { localStorage } from "@dovenv/utils" * * // Creates a local storage instance in the './myStorage' directory * const storage = localStorage('./myStorage'); * // Sets an item in the local storage * storage.setItem('key', 'value'); * // Retrieves the value of the item from the local storage * const value = storage.getItem('key'); */ declare function localStorage(location: string): LocalStorage; /** * Opens a system file or URL. * * @param {string} target - The file path or URL to open. * @example import { open } from "@dovenv/utils" * * // Opens the image in the default image viewer. * await open('pigeon.png', {wait: true}); */ declare const open: typeof o.default; /** * Open an app. Cross-platform. * * @param {string} name - The app you want to open. Can be either builtin supported apps names or other name supported in platform. * @example import { openApp } from "@dovenv/utils" * * // Open Xcode * await openApp('xcode'); */ declare const openApp: typeof o.openApp; /** * Resolves the directory path of a specified module entry. * * @param {object} opts - An object with options for resolving the module path. * @param {string} opts.id - The module entry name to resolve, such as a package name. * @param {string[]} opts.path - Optional additional path segments to join with the resolved module directory. * @param {string} opts.from - The path to resolve the module from. Defaults to the current working directory. * @returns {string} - The resolved directory path of the module. * @throws {Error} If the module cannot be found in the lookup paths. * @example * * const moduleDir = await getModulePath({ id: '@dovenv/utils' }) * console.log(moduleDir) // returns: {workspace}/node_modules/@dovenv/utils * * const moduleFile = await getModulePath({ id: '@dovenv/utils', path: ['dist','main.mjs'] }) * console.log(moduleFile) // returns: {workspace}/node_modules/@dovenv/utils/index.js */ declare const getModulePath: ({ from, id, path, }: { /** * The path to resolve the module from. * * @default process.cwd() */ from?: string; /** The module entry name to resolve, such as a package name*/ id: string; /** Optional additional path segments to join with the resolved module directory. */ path?: string[]; }) => Promise<string>; declare const getFileText: (path: string) => Promise<string>; /** * Fetch content from a URL to string. * * @param {string} url - URL of the resource. * @returns {Promise<string>} - The fetched content. * @throws {Error} If there is an error fetchi