creatium 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,1117 +1,23 @@
1
- import { boxen } from '@visulima/boxen';
2
- import { TableConstructorOptions } from 'cli-table3';
3
- import columnify from 'columnify';
4
- import * as p from '@clack/prompts';
5
- import * as fs from 'fs';
6
- import { readFile as readFile$1, writeFile as writeFile$1 } from 'node:fs/promises';
7
- import glob from 'tiny-glob';
8
- import { homedir } from 'node:os';
9
- import node_process from 'node:process';
10
- export { default as currentProcess } from 'node:process';
11
- import { deepmerge, deepmergeCustom } from 'deepmerge-ts';
12
- export { deepmerge, deepmergeCustom } from 'deepmerge-ts';
13
- import { fileURLToPath } from 'node:url';
14
- export { fileURLToPath } from 'node:url';
1
+ import { Prettify, color, prompt, line, ObjectValues, Response, ContentInput, ObjectToArray, copyDir, replacePlaceholders, getPaths } from './utils.mjs';
15
2
  import { ClippiumData } from 'clippium';
16
-
17
- declare const isBrowser: boolean;
18
- declare const isNode: boolean;
19
- declare const isWebWorker: boolean;
20
- declare const isJsDom: boolean;
21
- declare const isDeno: boolean;
22
- declare const isBun: boolean;
23
- /**
24
- * True if the environment is a development environment.
25
- */
26
- declare const isDev: boolean;
27
-
28
- declare const env: {
29
- isBrowser: boolean;
30
- isWebWorker: boolean;
31
- isNode: boolean;
32
- isJsDom: boolean;
33
- isDeno: boolean;
34
- isBun: boolean;
35
- };
36
-
37
- /**
38
- * Executes a command in the shell and waits for it to finish.
39
- *
40
- * @param {string} cmd - The command to execute.
41
- * @returns {Promise<void>} - A promise that resolves when the command finishes successfully.
42
- * @throws {Error} - Throws an error if the command fails.
43
- */
44
- declare const exec: (cmd: string) => Promise<void>;
45
- /**
46
- * Executes a command in a child process and captures its output.
47
- *
48
- * @param {string} cmd - The command to execute.
49
- * @returns {Promise<{ stdout: string; stderr: string }>} - A promise that resolves with the output of the command.
50
- * @throws {Error} - Throws an error if the command fails, along with its stdout and stderr.
51
- */
52
- declare const execChild: (cmd: string) => Promise<{
53
- stdout: string;
54
- stderr: string;
55
- }>;
56
- /**
57
- * Executes a command and captures its output.
58
- *
59
- * @param {string} command - The command to execute, including any arguments.
60
- * @returns {Promise<string>} A promise that resolves with the captured output (stdout).
61
- * @throws Will reject with an error if the command fails.
62
- * @example
63
- * const [error, output] = await catchExecOutput('dovenv --help')
64
- * if (error) {
65
- * console.error(error);
66
- * } else {
67
- * await writeFile('dovenvHelp.txt', output)
68
- * }
69
- */
70
- declare const catchExecOutput: <Res = string>(command: string) => Promise<[Error] | [undefined, Res]>;
71
- declare const existsLocalBin: (binName: string) => Promise<boolean>;
72
- declare const existsLocalBins: <Bin extends string>(binaries: Bin[]) => Promise<{ [key in Bin]: boolean; }>;
73
-
74
- /**
75
- * Prompt for number type.
76
- *
77
- * @param {NumberParams} opts - NumberOptions.
78
- * @returns {Promise<number | symbol>} - Promise resolving the answer.
79
- * @example
80
- * const age = await number({
81
- * message: 'What is your age?',
82
- * errorText: 'Failed getting age',
83
- * });
84
- * console.log(age)
85
- */
86
- declare function number(opts: NumberParams): Promise<number | symbol>;
87
-
88
- type GradientColors = string[] | {
89
- color: string;
90
- pos: number;
91
- }[];
92
- type GradientOpts = {
93
- /**
94
- 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.
95
- Defaults to rgb. Case insentitive.
96
- */
97
- interpolation?: 'rgb' | 'hsv';
98
- /**
99
- Used only in the case of HSV interpolation.
100
- Because hue can be considered as a circle, there are two ways to go from a color to another color.
101
- HsvSpin can be either short or long, depending on if you want to take the shortest or the longest way between two colors.
102
- Defaults to short. Case insensitive.
103
- */
104
- hsvSpin?: 'short' | 'long';
105
- };
106
-
107
- /**
108
- * Provides colors for terminal output.
109
- *
110
- * @type {object}
111
- * @example
112
- * console.log(color.green('This text is green'));
113
- */
114
- declare const color: Record<"black" | "blackBright" | "blue" | "blueBright" | "cyan" | "cyanBright" | "gray" | "green" | "greenBright" | "grey" | "magenta" | "magentaBright" | "red" | "redBright" | "white" | "whiteBright" | "yellow" | "yellowBright" | "bgBlack" | "bgBlackBright" | "bgBlue" | "bgBlueBright" | "bgCyan" | "bgCyanBright" | "bgGray" | "bgGreen" | "bgGreenBright" | "bgGrey" | "bgMagenta" | "bgMagentaBright" | "bgRed" | "bgRedBright" | "bgWhite" | "bgWhiteBright" | "bgYellow" | "bgYellowBright" | "blink" | "bold" | "dim" | "doubleunderline" | "framed" | "hidden" | "inverse" | "italic" | "overlined" | "reset" | "strikethrough" | "underline", (v: string) => string>;
115
- /**
116
- * Generates a gradient string with the specified colors.
117
- *
118
- * @param {string} txt - The text to apply the gradient to.
119
- * @param {GradientColors} colors - An array of color names or hex values.
120
- * @param {GradientOpts} [opts] - Custom opts.
121
- * @returns {string} - The text with the applied gradient.
122
- * @example
123
- * // Example usage:
124
- * const gradientText = gradient('Gradient Text', ['red', 'yellow', 'green']);
125
- * console.log(gradientText);
126
- */
127
- declare const gradient: (txt: string, colors: GradientColors, opts?: GradientOpts) => string;
128
-
129
- declare const line: ({ title, lineChar, align, }: {
130
- title?: string;
131
- lineChar?: string;
132
- align?: "left" | "center" | "right";
133
- }) => string;
134
-
135
- type TableData = string[][];
136
- type BoxOpts = Parameters<typeof boxen>[1];
137
- type ColumnOpts = columnify.GlobalOptions;
138
- type ColumnData = Record<string, unknown> | Record<string, unknown>[];
139
- /**
140
- * Generates a text-based table from the provided data array.
141
- *
142
- * @param {TableData} data - The data to display in the table.
143
- * @param {TableOpts} [options] - Optional configuration options for the table.
144
- * @returns {string} - The text-based table.
145
- * @see https://www.npmjs.com/package/table
146
- * @example
147
- * const data = [
148
- * ['Name', 'Age', 'Country'],
149
- * ['John', 30, 'USA'],
150
- * ['Alice', 25, 'UK'],
151
- * ['Bob', 35, 'Canada'],
152
- * ];
153
- * const tableText = table(data);
154
- * console.log(tableText);
155
- */
156
- declare const table: (data: TableData, options?: TableConstructorOptions) => string;
157
- /**
158
- * Creates a styled box around the provided text.
159
- *
160
- * @param {string} text - The text to display inside the box.
161
- * @param {BoxOpts} [options] - Optional configuration options for the box.
162
- * @returns {string} - The text with the styled box around it.
163
- * @see https://www.npmjs.com/package/boxen
164
- * @example
165
- * const boxedText = box('This is a boxed text', { padding: 1 });
166
- * console.log(boxedText);
167
- */
168
- declare const box: (text: string, options?: BoxOpts) => string;
169
- /**
170
- * Formats data into aligned columns for better readability.
171
- *
172
- * @param {ColumnData} data - The data to format into columns.
173
- * @param {ColumnOpts} [options] - Optional configuration options for column formatting.
174
- * @returns {string} - The text with the data formatted into columns.
175
- * @see https://www.npmjs.com/package/columnify
176
- * @example
177
- * // data for columns
178
- * const data = [
179
- * {
180
- * name: 'mod1',
181
- * description: 'some description which happens to be far larger than the max',
182
- * version: '0.0.1',
183
- * },
184
- * {
185
- * name: 'module-two',
186
- * description: 'another description larger than the max',
187
- * version: '0.2.0',
188
- * }
189
- * ];
190
- *
191
- * // set columns with custom config
192
- * const columnText = columns(data, {
193
- * showHeaders: false,
194
- * minWidth: 20,
195
- * config: {
196
- * description: {
197
- * maxWidth: 30
198
- * }
199
- * }
200
- * });
201
- *
202
- * // print columns
203
- * console.log(columnText);
204
- */
205
- declare const columns: <Data extends ColumnData>(data: Data, options?: ColumnOpts) => string;
206
-
207
- type EmptyObject = {};
208
- /**
209
- * Any Array type
210
- * Same as `any[]` type. Used only for prevent ts errors
211
- */
212
- type AnyArray = any[];
213
- /**
214
- * Any type
215
- * Same as `any` type. Used only for prevent ts errors
216
- */
217
- type Any = any;
218
- /**
219
- * Values of Object
220
- */
221
- type ObjectValues<Values> = Values[keyof Values];
222
- /**
223
- * Keys of Object
224
- */
225
- type ObjectKeys<Values> = keyof Values;
226
- /**
227
- * DeepPartial
228
- */
229
- type DeepPartial<T> = T extends object ? {
230
- [P in keyof T]?: DeepPartial<T[P]>;
231
- } : T;
232
- /**
233
- * Prettify your type for better readability
234
- */
235
- type Prettify<T> = {
236
- [K in keyof T]: T[K];
237
- } & {};
238
- /**
239
- * NonUndefined
240
- *
241
- * @description Exclude undefined from set `A`
242
- * @example
243
- * // Expect: "string | null"
244
- * SymmetricDifference<string | null | undefined>;
245
- */
246
- type NonUndefined<A> = A extends undefined ? never : A;
247
- /**
248
- * FunctionKeys
249
- *
250
- * @description Get union type of keys that are functions in object type `T`
251
- * @example
252
- * type MixedProps = {name: string; setName: (name: string) => void; someKeys?: string; someFn?: (...args: any) => any;};
253
- *
254
- * // Expect: "setName | someFn"
255
- * type Keys = FunctionKeys<MixedProps>;
256
- */
257
- type FunctionKeys<T extends object> = {
258
- [K in keyof T]-?: NonUndefined<T[K]> extends Function ? K : never;
259
- }[keyof T];
260
- /**
261
- * NonFunctionKeys
262
- *
263
- * @description Get union type of keys that are non-functions in object type `T`
264
- * @example
265
- * type MixedProps = {name: string; setName: (name: string) => void; someKeys?: string; someFn?: (...args: any) => any;};
266
- *
267
- * // Expect: "name | someKey"
268
- * type Keys = NonFunctionKeys<MixedProps>;
269
- */
270
- type NonFunctionKeys<T extends object> = {
271
- [K in keyof T]-?: NonUndefined<T[K]> extends Function ? never : K;
272
- }[keyof T];
273
- /**
274
- * AssertEqual
275
- *
276
- * @description Checks if two types `T` and `U` are equal.
277
- * @example
278
- * type Test = AssertEqual<string, string>; // Expected: true
279
- * type TestFail = AssertEqual<string, number>; // Expected: false
280
- */
281
- type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends (<V>() => V extends U ? 1 : 2) ? true : false;
282
- /**
283
- * ExpectEqual
284
- *
285
- * @description Returns the type `T` if `T` and `U` are equal; otherwise, returns `never`.
286
- * @example
287
- * type Test = ExpectEqual<string, string>; // Expected: string
288
- * type TestFail = ExpectEqual<string, number>; // Expected: never
289
- */
290
- type ExpectEqual<T, U> = AssertEqual<T, U> extends true ? T : never;
291
- type SingleChar<T extends string = string> = T extends `${infer First}${infer Rest}` ? Rest extends '' ? First : never : never;
292
- type ObjectToArray<T extends Record<string, Any>, Key extends string = 'type'> = {
293
- [K in keyof T]: T[K] & {
294
- [k in Key]: K;
295
- };
296
- }[keyof T][];
297
-
298
- declare const promptLineMethods: {
299
- readonly message: "message";
300
- readonly info: "info";
301
- readonly success: "success";
302
- readonly step: "step";
303
- readonly warn: "warn";
304
- readonly warning: "warning";
305
- readonly error: "error";
306
- };
307
- type PromptLineMethod = typeof promptLineMethods[keyof typeof promptLineMethods];
308
- /**
309
- * NUMBER.
310
- *
311
- */
312
- type NumberParams = Prettify<p.TextOptions & {
313
- errorText?: string;
314
- }>;
315
- /**
316
- * Parameters of the `table` function from the `@dovenv/utils` module.
317
- *
318
- * [See module](https://clippo.pigeonposse.com/guide/utils/style#table).
319
- */
320
- type TableParams = Parameters<typeof table>;
321
- /**
322
- * Parameters of the `columns` function from the `@dovenv/utils` module.
323
- *
324
- * [See module](https://clippo.pigeonposse.com/guide/utils/styles#columns).
325
- */
326
- type ColumnsParams = Parameters<typeof columns>;
327
- /**
328
- * Parameters of the `box` function from the `@dovenv/utils` module.
329
- *
330
- * [See module](https://clippo.pigeonposse.com/guide/utils/styles#box).
331
- */
332
- type BoxParams = Parameters<typeof box>;
333
-
334
- declare const prompt: {
335
- table: (opts: {
336
- value: TableParams[0];
337
- opts?: TableParams[1];
338
- type?: PromptLineMethod;
339
- }) => void;
340
- columns: (opts: {
341
- value: ColumnsParams[0];
342
- opts?: ColumnsParams[1];
343
- type?: PromptLineMethod;
344
- }) => void;
345
- box: (opts: {
346
- value: BoxParams[0];
347
- opts?: BoxParams[1];
348
- type?: PromptLineMethod;
349
- }) => void;
350
- number: typeof number;
351
- isCancel: typeof p.isCancel;
352
- updateSettings: typeof p.updateSettings;
353
- cancel: (message?: string) => void;
354
- confirm: (opts: p.ConfirmOptions) => Promise<boolean | symbol>;
355
- group: <T>(prompts: p.PromptGroup<T>, opts?: p.PromptGroupOptions<T> | undefined) => Promise<{ [P in keyof p.PromptGroupAwaitedReturn<T>]: p.PromptGroupAwaitedReturn<T>[P]; }>;
356
- groupMultiselect: <Value>(opts: p.GroupMultiSelectOptions<Value>) => Promise<symbol | Value[]>;
357
- intro: (title?: string) => void;
358
- log: {
359
- message: (message?: string, { symbol }?: p.LogMessageOptions) => void;
360
- info: (message: string) => void;
361
- success: (message: string) => void;
362
- step: (message: string) => void;
363
- warn: (message: string) => void;
364
- warning: (message: string) => void;
365
- error: (message: string) => void;
366
- };
367
- multiselect: <Value>(opts: p.MultiSelectOptions<Value>) => Promise<symbol | Value[]>;
368
- note: (message?: string, title?: string) => void;
369
- outro: (message?: string) => void;
370
- password: (opts: p.PasswordOptions) => Promise<string | symbol>;
371
- select: <Value>(opts: p.SelectOptions<Value>) => Promise<symbol | Value>;
372
- selectKey: <Value extends string>(opts: p.SelectOptions<Value>) => Promise<symbol | Value>;
373
- spinner: ({ indicator }?: p.SpinnerOptions) => {
374
- start: (msg?: string) => void;
375
- stop: (msg?: string, code?: number) => void;
376
- message: (msg?: string) => void;
377
- };
378
- stream: {
379
- message: (iterable: Iterable<string> | AsyncIterable<string>, { symbol }?: p.LogMessageOptions) => Promise<void>;
380
- info: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
381
- success: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
382
- step: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
383
- warn: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
384
- warning: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
385
- error: (iterable: Iterable<string> | AsyncIterable<string>) => Promise<void>;
386
- };
387
- tasks: (tasks: p.Task[]) => Promise<void>;
388
- text: (opts: p.TextOptions) => Promise<string | symbol>;
389
- };
390
-
391
- type ParamFn = (arg: string) => Promise<string>;
392
- type ParamsValue = string | number | Record<string, unknown> | unknown[] | unknown;
393
- type Params = Record<string, ParamsValue>;
394
- type Props = {
395
- /** Content to be replaced */
396
- content: string;
397
- /**
398
- * Parameters
399
- *
400
- * @example
401
- * const params = {
402
- * name: 'Antonio',
403
- * lastName : 'Resines'
404
- * }
405
- */
406
- params: Params;
407
- /**
408
- * Transform parameters insde placeholders.
409
- *
410
- * @example
411
- * const transform = async ( param: string ) => {
412
- * if ( param === 'url' ) return 'https://pigeonposse.com',
413
- * else if ( param === 'http://pigeonposse.com' ) return 'https://pigeonposse.com'
414
- * return param
415
- * }
416
- */
417
- transform?: ParamFn;
418
- /** Options */
419
- opts?: {
420
- /**
421
- * Throw an error if a placeholder is not found.
422
- *
423
- * @default false
424
- */
425
- throw?: boolean;
426
- /**
427
- * Throw an error if a parameter is not found.
428
- *
429
- * @default
430
- * {
431
- * prefix : '{{',
432
- * suffix : '}}',
433
- * }
434
- */
435
- mark?: {
436
- prefix: string;
437
- suffix: string;
438
- };
439
- };
440
- };
441
- /**
442
- * Replace placeholders in a string with their corresponding values.
443
- *
444
- * The function takes a string with placeholders, an object with parameter values,
445
- * and an optional custom parameter function.
446
- *
447
- * The function returns a Promise that resolves to the string with all placeholders
448
- * replaced.
449
- *
450
- * @param {Props} props - Props for the function.
451
- * @param {Props['content']} props.content - The string with placeholders.
452
- * @param {Props['params']} props.params - An object with parameter values.
453
- * @param {Props['transform']} [props.transform] - An optional custom parameter function.
454
- * @param {Props['opts']} [props.opts] - Options to customize the behavior of the function.
455
- * @returns {Promise<string>} - A Promise that resolves to the string with all placeholders replaced.
456
- */
457
- declare const replacePlaceholders: (props: Props) => Promise<string>;
458
-
459
- declare const getStringType: (value: string) => "text" | "url" | "path";
460
- /**
461
- * Joins the given URL parts into a single string.
462
- *
463
- * @param {string[]} parts - The URL parts to join.
464
- * @returns {string} - The joined URL string.
465
- */
466
- declare const joinUrl: (...parts: string[]) => string;
467
- /**
468
- * Converts an object to a JSON string.
469
- *
470
- * @param {unknown} data - The data to convert to a string.
471
- * @returns {string} - The JSON string representation of the data.
472
- */
473
- declare const object2string: (data: unknown) => string;
474
- /**
475
- * Truncates a given string to a maximum length and adds an ellipsis (...) at the end.
476
- *
477
- * @param {string} text - The string to truncate.
478
- * @param {number} maxLength - The maximum length of the string.
479
- * @param {string} [ellipsis] - The ellipsis to add at the end of the truncated string (default is '…').
480
- * @returns {string} - The truncated string.
481
- */
482
- declare const truncate: (text: string, maxLength: number, ellipsis?: string) => string;
483
-
484
- declare const resolvePath: (...paths: string[]) => string;
485
- declare const relativePath: (from: string, to: string) => string;
486
- declare const getExtName: (path: string) => string;
487
- declare const getDirName: (path: string) => string;
488
- declare const getBaseName: (path: string, suffix?: string) => string;
489
- declare const isAbsolutePath: (path: string) => boolean;
490
- declare const normalizePath: (path: string) => string;
491
-
492
- declare const writeFile: typeof writeFile$1;
493
- /**
494
- * Find files and directories using glob patterns.
495
- *
496
- */
497
- declare const getPaths: typeof glob;
498
- /**
499
- * Checks if two file paths are equal after normalization.
500
- * Normalization ensures that differences like trailing slashes or redundant path segments are ignored.
501
- *
502
- * ---
503
- *
504
- * @param {string} path1 - The first file path to compare.
505
- * @param {string} path2 - The second file path to compare.
506
- * @returns {boolean} `true` if the paths are equal, `false` otherwise.
507
- */
508
- declare const arePathsEqual: (path1: string, path2: string) => boolean;
509
- /**
510
- * Check if a string is a valid path.
511
- *
512
- * @param {string} str - The string to test.
513
- * @returns {boolean} True if the string is a valid path.
514
- * @example
515
- * isPath('..') // true
516
- * isPath('foo bar') // false
517
- * isPath('C:\\') // true
518
- * isPath('foo\\bar') // true
519
- * isPath('foo/bar') // true
520
- * isPath('foo bar/baz') // false
521
- */
522
- declare const isPath: (str: string) => boolean;
523
- /**
524
- * Creates a directory if it does not exist.
525
- *
526
- * @param {string} path - Path to the directory to create.
527
- * @returns {Promise<void>} - A promise that resolves when the directory has been created.
528
- * @example
529
- * await ensureDir('./path/to/directory')
530
- */
531
- declare const ensureDir: (path: string) => Promise<void>;
532
- /**
533
- * Reads the contents of a directory.
534
- *
535
- * @param {string} path - Path to the directory to read.
536
- * @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.
537
- * @example
538
- * const dirItems = await readDir('./path/to/directory')
539
- */
540
- declare const readDir: (path: string) => Promise<fs.Dirent<string>[]>;
541
- /**
542
- * Gets the file names in a directory and filters them by extension.
543
- *
544
- * @param {object} props - Function props.
545
- * @param {string} props.path - Path to the directory.
546
- * @param {string[]} props.extensions - Array of extensions to filter by, e.g., ['.md', '.txt'].
547
- * @returns {Promise<string[]>} - A promise that resolves with an array of file names without extensions.
548
- */
549
- declare function getFilteredFileNames({ path, extensions, }: {
550
- path: string;
551
- extensions: string[];
552
- }): Promise<string[]>;
553
- /**
554
- * Gets the current directory.
555
- *
556
- * @param {string} [path] - An optional path to resolve the directory from.
557
- * @returns {string} - The current directory.
558
- * @example getCurrentDir()
559
- */
560
- declare const getCurrentDir: (path?: string) => string;
561
- /**
562
- * Joins path segments.
563
- *
564
- * @param {...string} paths - Path segments to join.
565
- * @returns {string} - The joined path.
566
- * @example joinPath('user', 'pigeonposse')
567
- */
568
- declare function joinPath(...paths: string[]): string;
569
- /**
570
- * Resolves path segments into an absolute path.
571
- *
572
- * @param {...string} paths - Path segments to resolve.
573
- * @returns {string} - The resolved absolute path.
574
- */
575
- declare const getAbsolutePath: (...paths: string[]) => string;
576
- /**
577
- * Validates and resolves a path with home directory replacement.
578
- *
579
- * @param {string} path - The path to validate and resolve.
580
- * @returns {string} - The validated and resolved absolute path.
581
- * @example
582
- * import { validateHomeDir } from '@dovenv/utils'
583
- *
584
- * const path = validateHomeDir('~/Documents')
585
- *
586
- * console.log(path) // returns: /users/{username}/Documents
587
- *
588
- * const path = validateHomeDir('/Home')
589
- *
590
- * console.log(path) // returns same: /Home
591
- */
592
- declare function validateHomeDir(path: string): string;
593
- /**
594
- * Reads the content of a file at the specified path.
595
- *
596
- * @param {string} path - The path of the file to read.
597
- * @returns {Promise<string | Buffer>} - A promise that resolves to the content of the file as a string or buffer.
598
- * @throws {Error} If an error occurs while reading the file.
599
- * @example import { readFile } from '@dovenv/utils'
600
- *
601
- * try {
602
- * const content = await readFile('./example.txt');
603
- * console.log(content);
604
- * } catch (error) {
605
- * console.error('Error reading file:', error);
606
- * }
607
- */
608
- declare const readFile: typeof readFile$1;
609
- /**
610
- * Removes a directory and its contents if it exists.
611
- *
612
- * @param {string} path - The path of the directory to remove.
613
- * @throws {Error} If an error occurs while removing the directory.
614
- * @example import { removeDir } from '@dovenv/utils'
615
- *
616
- * try {
617
- * await removeDir('./my/path')
618
- * } catch (e) {
619
- * console.log(e)
620
- * }
621
- */
622
- declare function removeDir(path: string): Promise<void>;
623
- /**
624
- * Removes a directory and its contents if it exists.
625
- *
626
- * @param {string} path - The path of the directory to remove.
627
- * @throws {Error} If an error occurs while removing the directory.
628
- * @example import { removeDirIfExist } from '@dovenv/utils'
629
- *
630
- * await removeDirIfExist('./my/path')
631
- */
632
- declare function removeDirIfExist(path: string): Promise<void>;
633
- /**
634
- * Removes a file or directory if it exists.
635
- *
636
- * @param {string} path - The path of the file or directory to remove.
637
- * @throws {Error} If an error occurs while removing the file or directory.
638
- * @example
639
- * try {
640
- * await removePathIfExist('./my/path')
641
- * } catch (e) {
642
- * console.log(e)
643
- * }
644
- */
645
- declare function removePathIfExist(path: string): Promise<void>;
646
- /**
647
- * Removes a file if it exists.
648
- *
649
- * @param {string} path - The path of the file to remove.
650
- * @throws {Error} If an error occurs while removing the file.
651
- * @example
652
- * try {
653
- * await removeFile('./my/path')
654
- * } catch (e) {
655
- * console.log(e)
656
- * }
657
- */
658
- declare function removeFileIfExist(path: string): Promise<void>;
659
- /**
660
- * Removes a file.
661
- *
662
- * @param {string} path - The path of the file to remove.
663
- * @throws {Error} If an error occurs while removing the file.
664
- * @example
665
- * try {
666
- * await removeFile('./my/path')
667
- * } catch (e) {
668
- * console.log(e)
669
- * }
670
- */
671
- declare function removeFile(path: string): Promise<void>;
672
- /**
673
- * Checks if the given path points to a directory.
674
- *
675
- * @param {string} path - The path to check.
676
- * @returns {Promise<boolean>} - A promise that resolves to true if the path points to a directory, otherwise false.
677
- * @example import { isDirectory } from '@dovenv/utils'
678
- *
679
- * const isDir = await isDirectory('./my/path')
680
- */
681
- declare function isDirectory(path: string): Promise<boolean>;
682
- /**
683
- * Creates a directory at the specified path.
684
- *
685
- * @param {string} path - The path of the directory to create.
686
- * @throws {Error} If an error occurs while creating the directory.
687
- * @example import { createDir } from '@dovenv/utils'
688
- * await createDir('./my/dir')
689
- */
690
- declare function createDir(path: string): Promise<void>;
691
- /**
692
- * Checks if a directory exists at the specified path.
693
- *
694
- * @param {string} path - The path to check.
695
- * @returns {Promise<boolean>} - A promise that resolves to true if a directory exists at the specified path, otherwise false.
696
- * @example import { existsDir } from '@dovenv/utils'
697
- * const exist = await existsDir('./my/dir')
698
- */
699
- declare function existsDir(path: string): Promise<boolean>;
700
- /**
701
- * Checks if a file exists at the specified path.
702
- *
703
- * @param {string} path - The path to the file.
704
- * @returns {Promise<boolean>} - A promise that resolves to true if the file exists, otherwise false.
705
- * @throws {Error} If an error occurs while checking the existence of the file.
706
- * @example import { existsFile } from '@dovenv/utils'
707
- *
708
- * const existPKG = await existsFile('./package.json')
709
- */
710
- declare function existsFile(path: string): Promise<boolean>;
711
- /**
712
- * Writes content to a file at the specified path.
713
- *
714
- * @param {string} path - The path of the file to write to.
715
- * @param {string | Buffer} content - The content to write to the file.
716
- * @throws {Error} If an error occurs while writing to the file.
717
- * @example import { writeFileContent } from '@dovenv/utils'
718
- *
719
- * await writeFileContent('./greetFile.txt', 'Hello')
720
- */
721
- declare function writeFileContent(path: string, content: string | Buffer): Promise<void>;
722
- /**
723
- * Checks if a file or directory exists at the specified path.
724
- *
725
- * @param {string} path - The path to check.
726
- * @returns {Promise<boolean>} - A promise that resolves to true if a file or directory exists at the specified path, otherwise false.
727
- * @throws {Error} If an error occurs while checking the existence of the path.
728
- * @example import { existsPath } from '@dovenv/utils'
729
- *
730
- * const existPKG = await existsPath('./package.json')
731
- */
732
- declare function existsPath(path: string): Promise<boolean>;
733
- /**
734
- * Creates a symbolic link from the input path to the output path.
735
- *
736
- * @param {{input: string, output: string}} options - Options object with input and output paths.
737
- * @returns {Promise<void>} - Resolves when the symbolic link has been created.
738
- * @throws {Error} If there is an error creating the symbolic link.
739
- * @example import { createSymlink } from '@dovenv/utils'
740
- *
741
- * const symlinkResult = await createSymlink({
742
- * input : '/path/to/source',
743
- * output: '/path/to/destination',
744
- * })
745
- */
746
- declare const createSymlink: ({ input, output, }: {
747
- input: string;
748
- output: string;
749
- }) => Promise<void>;
750
-
751
- type ContentInput = {
752
- /**
753
- * The name of the file
754
- *
755
- * @example 'index.html'
756
- * @example 'src/index.js'
757
- */
758
- path: string;
759
- content: string | Buffer;
760
- };
761
- type CopyDirOptions = {
762
- /**
763
- * The path of the directory to copy or an array of files and directories to copy.
764
- */
765
- input: ContentInput[] | string;
766
- /**
767
- * The path of the destination directory.
768
- */
769
- output: string;
770
- };
771
- declare const getContentDir: (input: string, opts?: Omit<Parameters<typeof getPaths>[1], "cwd" | "filesOnly"> & {
772
- pattern?: string;
773
- encoding?: Parameters<typeof readFile>[1];
774
- }) => Promise<ContentInput[]>;
775
- /**
776
- * Copy a file from input path to output path.
777
- *
778
- * @param {{input: string, output: string}} options - Options object with input and output paths.
779
- * @returns {Promise<void>} - Resolves when the file has been copied.
780
- * @throws {Error} If there is an error copying the file.
781
- * @example import { copyFile } from '@dovenv/utils'
782
- *
783
- * const copyResult = await copyFile({
784
- * input : '/path/to/source.txt',
785
- * output: '/path/to/destination.txt',
786
- * })
787
- */
788
- declare const copyFile: ({ input, output, }: {
789
- input: string;
790
- output: string;
791
- }) => Promise<void>;
792
- /**
793
- * Copy a directory from input path to output path.
794
- *
795
- * @param {{input: string, output: string}} options - Options object with input and output paths.
796
- * @returns {Promise<void>} - Resolves when the directory has been copied.
797
- * @throws {Error} If there is an error copying the directory.
798
- * @example
799
- *
800
- * const copyResult = await copyDir({
801
- * input : '/path/to/sourceDir',
802
- * output: '/path/to/destinationDir',
803
- * })
804
- *
805
- * const copyResult = await copyDir({
806
- * input : [
807
- * { name: 'file1.txt', content: 'Hello, world!' },
808
- * { name: 'subfolder/subfile.txt', content: 'Subfolder content' } },
809
- * ],
810
- * output: '/path/to/destinationDir',
811
- })
812
- */
813
- declare const copyDir: ({ input, output, }: CopyDirOptions) => Promise<void>;
814
-
815
- declare const getHomeDir: typeof homedir;
816
- /**
817
- * Returns the path to the operating system's temporary directory.
818
- *
819
- * @returns {string} The path to the operating system's temporary directory.
820
- */
821
- declare const getTempDir: () => string;
822
- /**
823
- * Determines the operating system.
824
- *
825
- * @returns {'windows' | 'macos' | 'linux' | 'unknown'} - The operating system. Possible values are 'linux', 'macos', or 'windows'.
826
- */
827
- declare const getPlatform: () => Promise<"windows" | "macos" | "linux" | "unknown">;
828
- /**
829
- * Returns the operating system CPU architecture.
830
- *
831
- * @returns {'arm64' | 'x64' | 'unknown'} - The operating system CPU architecture.
832
- */
833
- declare function getArch(): 'arm64' | 'x64' | 'unknown';
834
-
835
- declare const getSystemEnvPaths: ({ name, suffix, }: {
836
- name: string;
837
- suffix?: string;
838
- }) => {
839
- data: string;
840
- config: string;
841
- cache: string;
842
- log: string;
843
- temp: string;
844
- };
845
-
846
- type CacheOptions<Values extends Record<string, unknown>> = {
847
- /**
848
- * Project name for search cache.
849
- * You can reuse the same cache for multiple instances.
850
- */
851
- projectName: string;
852
- /**
853
- * Identifier for the values.
854
- */
855
- id: string;
856
- /**
857
- * Cache Default Values.
858
- */
859
- values: Values;
860
- /**
861
- * Directory to save cache file.
862
- * Default: System default user config directory.
863
- * You most likely don't need this. Please don't use it unless you really have to.
864
- */
865
- cwd?: string;
866
- /**
867
- * Suffix for cache directory.
868
- */
869
- suffix?: string;
870
- };
871
- /**
872
- * Creates a caching mechanism for storing and retrieving values.
873
- *
874
- * @param {object} opts - Parameters for configuring the cache.
875
- * @returns {object} - An object with methods to interact with the cache.
876
- * @throws {Error} If the cache value is unexpected or not found.
877
- * @example
878
- *
879
- * const { get, set } = await cache({
880
- * projectName: 'myApp',
881
- * id: 'userSettings',
882
- * values: {
883
- * theme: 'dark',
884
- * language: 'en'
885
- * },
886
- * });
887
- *
888
- * // Set a new value in the cache
889
- * set({ theme: 'light' });
890
- *
891
- * // Retrieve a value from the cache
892
- * const theme = get('theme');
893
- * console.log(theme); // Output: 'light'
894
- *
895
- * // Retrieve all cached values
896
- * const allValues = get();
897
- * console.log(allValues); // Output: { theme: 'light', language: 'en' }
898
- *
899
- * // Handle unexpected cache value
900
- * try {
901
- * const nonExistentValue = get('nonExistent');
902
- * } catch (error) {
903
- * console.error('Error:', error.message); // Output: Cache value is unexpected: nonExistent
904
- * }
905
- */
906
- declare const cache: <Values extends Record<string, unknown>>(opts: CacheOptions<Values>) => Promise<{
907
- /**
908
- * The default values for the cache.
909
- */
910
- defaultValues: Values;
911
- /**
912
- * Retrieve a value from the cache.
913
- *
914
- * @example
915
- * const theme = get('theme');
916
- * console.log(theme); // Output: 'light'
917
- */
918
- get: <ID extends string | undefined = undefined>(v?: ID) => Promise<ID extends keyof Values ? Values[ID] : ID extends string ? undefined : Values>;
919
- /**
920
- * Updates the cache with the provided values.
921
- *
922
- * Merges the existing cached values with the new partial values and updates the cache.
923
- */
924
- set: (obj: Partial<Values>) => Promise<void>;
925
- /**
926
- * Resets the cache to its default values.
927
- *
928
- * @example
929
- * reset();
930
- */
931
- reset: () => Promise<void>;
932
- /**
933
- * The path to the cache file.
934
- */
935
- path: string;
936
- }>;
937
-
938
- type CommonObj = Record<string, unknown> | Record<string, unknown>[] | unknown[];
939
- declare const getObjectFromJSONFile: <Res extends CommonObj = CommonObj>(path: string) => Promise<Res>;
940
-
941
- /**
942
- * Finds the closest package.json by traversing up the directory tree.
943
- *
944
- * @param {string} [startDir] - Directory to start searching from.
945
- * @returns {string} Absolute path to the closest package.json.
946
- * @throws {Error} If no package.json is found.
947
- */
948
- declare const getClosestPackageJson: (startDir?: string) => Promise<string>;
949
- /**
950
- * Finds the closest package directory by traversing up the directory tree.
951
- *
952
- * @param {string} [startDir] - Directory to start searching from.
953
- * @returns {string} Absolute path to the closest package directory.
954
- */
955
- declare const getClosestPackageDir: (startDir?: string) => Promise<string>;
956
-
957
- /**
958
- * DeepNonNullable
959
- *
960
- * @description NonNullable that works for deeply nested structure
961
- * @example
962
- * type NestedProps = {
963
- * first?: null | {
964
- * second?: null | {
965
- * name?: string | null |
966
- * undefined;
967
- * };
968
- * };
969
- * };
970
- * type RequiredNestedProps = DeepNonNullable<NestedProps>;
971
- * // Expect: {
972
- * // first: {
973
- * // second: {
974
- * // name: string;
975
- * // };
976
- * // };
977
- * // }
978
- */
979
- type DeepNonNullable<T> = Prettify<_DeepNonNullable<T>>;
980
- type _DeepNonNullable<T> = T extends (...args: AnyArray) => Any ? T : T extends AnyArray ? Prettify<Array<_DeepNonNullable<NonNullable<T[number]>>>> : T extends object ? Prettify<{
981
- [P in keyof T]-?: _DeepNonNullable<NonNullable<T[P]>>;
982
- }> : Prettify<NonNullable<T>>;
983
-
984
- type ReturnAwaitedType<T extends (...args: Any) => Any> = Awaited<ReturnType<T>>;
985
- type Response<V> = Promise<V> | V;
986
- type GetResponse<T> = T extends (...args: Any[]) => infer R ? Awaited<R> : T;
987
-
988
- /**
989
- * DeepRequired
990
- *
991
- * @description Required that works for deeply nested structure
992
- * @example
993
- * type NestedProps = {
994
- * first?: {
995
- * second?: {
996
- * name?: string;
997
- * };
998
- * };
999
- * };
1000
- * type RequiredNestedProps = DeepRequired<NestedProps>
1001
- * // Expect: {
1002
- * // first: {
1003
- * // second: {
1004
- * // name: string;
1005
- * // };
1006
- * // };
1007
- * // }
1008
- */
1009
- type DeepRequired<T> = Prettify<_DeepRequired<T>>;
1010
- type _DeepRequired<T> = T extends (...args: AnyArray) => Any ? T : T extends AnyArray ? Prettify<_DeepRequiredArray<T[number]>> : T extends object ? Prettify<_DeepRequiredObject<T>> : T;
1011
- type _DeepRequiredArray<T> = Array<_DeepRequired<NonUndefined<T>>>;
1012
- type _DeepRequiredObject<T> = {
1013
- [P in keyof T]-?: _DeepRequired<NonUndefined<T[P]>>;
1014
- };
1015
-
1016
- type __utils_Any = Any;
1017
- type __utils_AnyArray = AnyArray;
1018
- type __utils_AssertEqual<T, U> = AssertEqual<T, U>;
1019
- type __utils_CommonObj = CommonObj;
1020
- type __utils_ContentInput = ContentInput;
1021
- type __utils_CopyDirOptions = CopyDirOptions;
1022
- type __utils_DeepNonNullable<T> = DeepNonNullable<T>;
1023
- type __utils_DeepPartial<T> = DeepPartial<T>;
1024
- type __utils_DeepRequired<T> = DeepRequired<T>;
1025
- type __utils_EmptyObject = EmptyObject;
1026
- type __utils_ExpectEqual<T, U> = ExpectEqual<T, U>;
1027
- type __utils_FunctionKeys<T extends object> = FunctionKeys<T>;
1028
- type __utils_GetResponse<T> = GetResponse<T>;
1029
- type __utils_NonFunctionKeys<T extends object> = NonFunctionKeys<T>;
1030
- type __utils_NonUndefined<A> = NonUndefined<A>;
1031
- type __utils_ObjectKeys<Values> = ObjectKeys<Values>;
1032
- type __utils_ObjectToArray<T extends Record<string, Any>, Key extends string = 'type'> = ObjectToArray<T, Key>;
1033
- type __utils_ObjectValues<Values> = ObjectValues<Values>;
1034
- type __utils_Prettify<T> = Prettify<T>;
1035
- type __utils_Response<V> = Response<V>;
1036
- type __utils_ReturnAwaitedType<T extends (...args: Any) => Any> = ReturnAwaitedType<T>;
1037
- type __utils_SingleChar<T extends string = string> = SingleChar<T>;
1038
- declare const __utils_arePathsEqual: typeof arePathsEqual;
1039
- declare const __utils_box: typeof box;
1040
- declare const __utils_cache: typeof cache;
1041
- declare const __utils_catchExecOutput: typeof catchExecOutput;
1042
- declare const __utils_color: typeof color;
1043
- declare const __utils_columns: typeof columns;
1044
- declare const __utils_copyDir: typeof copyDir;
1045
- declare const __utils_copyFile: typeof copyFile;
1046
- declare const __utils_createDir: typeof createDir;
1047
- declare const __utils_createSymlink: typeof createSymlink;
1048
- declare const __utils_deepmerge: typeof deepmerge;
1049
- declare const __utils_deepmergeCustom: typeof deepmergeCustom;
1050
- declare const __utils_ensureDir: typeof ensureDir;
1051
- declare const __utils_env: typeof env;
1052
- declare const __utils_exec: typeof exec;
1053
- declare const __utils_execChild: typeof execChild;
1054
- declare const __utils_existsDir: typeof existsDir;
1055
- declare const __utils_existsFile: typeof existsFile;
1056
- declare const __utils_existsLocalBin: typeof existsLocalBin;
1057
- declare const __utils_existsLocalBins: typeof existsLocalBins;
1058
- declare const __utils_existsPath: typeof existsPath;
1059
- declare const __utils_fileURLToPath: typeof fileURLToPath;
1060
- declare const __utils_getAbsolutePath: typeof getAbsolutePath;
1061
- declare const __utils_getArch: typeof getArch;
1062
- declare const __utils_getBaseName: typeof getBaseName;
1063
- declare const __utils_getClosestPackageDir: typeof getClosestPackageDir;
1064
- declare const __utils_getClosestPackageJson: typeof getClosestPackageJson;
1065
- declare const __utils_getContentDir: typeof getContentDir;
1066
- declare const __utils_getCurrentDir: typeof getCurrentDir;
1067
- declare const __utils_getDirName: typeof getDirName;
1068
- declare const __utils_getExtName: typeof getExtName;
1069
- declare const __utils_getFilteredFileNames: typeof getFilteredFileNames;
1070
- declare const __utils_getHomeDir: typeof getHomeDir;
1071
- declare const __utils_getObjectFromJSONFile: typeof getObjectFromJSONFile;
1072
- declare const __utils_getPaths: typeof getPaths;
1073
- declare const __utils_getPlatform: typeof getPlatform;
1074
- declare const __utils_getStringType: typeof getStringType;
1075
- declare const __utils_getSystemEnvPaths: typeof getSystemEnvPaths;
1076
- declare const __utils_getTempDir: typeof getTempDir;
1077
- declare const __utils_gradient: typeof gradient;
1078
- declare const __utils_isAbsolutePath: typeof isAbsolutePath;
1079
- declare const __utils_isBrowser: typeof isBrowser;
1080
- declare const __utils_isBun: typeof isBun;
1081
- declare const __utils_isDeno: typeof isDeno;
1082
- declare const __utils_isDev: typeof isDev;
1083
- declare const __utils_isDirectory: typeof isDirectory;
1084
- declare const __utils_isJsDom: typeof isJsDom;
1085
- declare const __utils_isNode: typeof isNode;
1086
- declare const __utils_isPath: typeof isPath;
1087
- declare const __utils_isWebWorker: typeof isWebWorker;
1088
- declare const __utils_joinPath: typeof joinPath;
1089
- declare const __utils_joinUrl: typeof joinUrl;
1090
- declare const __utils_line: typeof line;
1091
- declare const __utils_normalizePath: typeof normalizePath;
1092
- declare const __utils_object2string: typeof object2string;
1093
- declare const __utils_prompt: typeof prompt;
1094
- declare const __utils_readDir: typeof readDir;
1095
- declare const __utils_readFile: typeof readFile;
1096
- declare const __utils_relativePath: typeof relativePath;
1097
- declare const __utils_removeDir: typeof removeDir;
1098
- declare const __utils_removeDirIfExist: typeof removeDirIfExist;
1099
- declare const __utils_removeFile: typeof removeFile;
1100
- declare const __utils_removeFileIfExist: typeof removeFileIfExist;
1101
- declare const __utils_removePathIfExist: typeof removePathIfExist;
1102
- declare const __utils_replacePlaceholders: typeof replacePlaceholders;
1103
- declare const __utils_resolvePath: typeof resolvePath;
1104
- declare const __utils_table: typeof table;
1105
- declare const __utils_truncate: typeof truncate;
1106
- declare const __utils_validateHomeDir: typeof validateHomeDir;
1107
- declare const __utils_writeFile: typeof writeFile;
1108
- declare const __utils_writeFileContent: typeof writeFileContent;
1109
- declare namespace __utils {
1110
- export { __utils_arePathsEqual as arePathsEqual, __utils_box as box, __utils_cache as cache, __utils_catchExecOutput as catchExecOutput, __utils_color as color, __utils_columns as columns, __utils_copyDir as copyDir, __utils_copyFile as copyFile, __utils_createDir as createDir, __utils_createSymlink as createSymlink, node_process as currentProcess, __utils_deepmerge as deepmerge, __utils_deepmergeCustom as deepmergeCustom, __utils_ensureDir as ensureDir, __utils_env as env, __utils_exec as exec, __utils_execChild as execChild, __utils_existsDir as existsDir, __utils_existsFile as existsFile, __utils_existsLocalBin as existsLocalBin, __utils_existsLocalBins as existsLocalBins, __utils_existsPath as existsPath, __utils_fileURLToPath as fileURLToPath, __utils_getAbsolutePath as getAbsolutePath, __utils_getArch as getArch, __utils_getBaseName as getBaseName, __utils_getClosestPackageDir as getClosestPackageDir, __utils_getClosestPackageJson as getClosestPackageJson, __utils_getContentDir as getContentDir, __utils_getCurrentDir as getCurrentDir, __utils_getDirName as getDirName, __utils_getExtName as getExtName, __utils_getFilteredFileNames as getFilteredFileNames, __utils_getHomeDir as getHomeDir, __utils_getObjectFromJSONFile as getObjectFromJSONFile, __utils_getPaths as getPaths, __utils_getPlatform as getPlatform, __utils_getStringType as getStringType, __utils_getSystemEnvPaths as getSystemEnvPaths, __utils_getTempDir as getTempDir, __utils_gradient as gradient, __utils_isAbsolutePath as isAbsolutePath, __utils_isBrowser as isBrowser, __utils_isBun as isBun, __utils_isDeno as isDeno, __utils_isDev as isDev, __utils_isDirectory as isDirectory, __utils_isJsDom as isJsDom, __utils_isNode as isNode, __utils_isPath as isPath, __utils_isWebWorker as isWebWorker, __utils_joinPath as joinPath, __utils_joinUrl as joinUrl, __utils_line as line, __utils_normalizePath as normalizePath, __utils_object2string as object2string, __utils_prompt as prompt, __utils_readDir as readDir, __utils_readFile as readFile, __utils_relativePath as relativePath, __utils_removeDir as removeDir, __utils_removeDirIfExist as removeDirIfExist, __utils_removeFile as removeFile, __utils_removeFileIfExist as removeFileIfExist, __utils_removePathIfExist as removePathIfExist, __utils_replacePlaceholders as replacePlaceholders, __utils_resolvePath as resolvePath, __utils_table as table, __utils_truncate as truncate, __utils_validateHomeDir as validateHomeDir, __utils_writeFile as writeFile, __utils_writeFileContent as writeFileContent };
1111
- export type { __utils_Any as Any, __utils_AnyArray as AnyArray, __utils_AssertEqual as AssertEqual, __utils_CommonObj as CommonObj, __utils_ContentInput as ContentInput, __utils_CopyDirOptions as CopyDirOptions, __utils_DeepNonNullable as DeepNonNullable, __utils_DeepPartial as DeepPartial, __utils_DeepRequired as DeepRequired, __utils_EmptyObject as EmptyObject, __utils_ExpectEqual as ExpectEqual, __utils_FunctionKeys as FunctionKeys, __utils_GetResponse as GetResponse, __utils_NonFunctionKeys as NonFunctionKeys, __utils_NonUndefined as NonUndefined, __utils_ObjectKeys as ObjectKeys, __utils_ObjectToArray as ObjectToArray, __utils_ObjectValues as ObjectValues, __utils_Prettify as Prettify, __utils_Response as Response, __utils_ReturnAwaitedType as ReturnAwaitedType, __utils_SingleChar as SingleChar };
1112
- }
3
+ import '@visulima/boxen';
4
+ import 'cli-table3';
5
+ import 'columnify';
6
+ import '@clack/prompts';
7
+ import 'fs';
8
+ import 'node:fs/promises';
9
+ import 'tiny-glob';
10
+ import 'node:os';
11
+ import 'node:process';
12
+ import 'deepmerge-ts';
13
+ import 'node:url';
1113
14
 
1114
15
  type Option = NonNullable<ClippiumData['flags']>[number];
16
+ type OptionsUtils = {
17
+ color: typeof color;
18
+ prompt: typeof prompt;
19
+ line: typeof line;
20
+ };
1115
21
  type OptionSuper = {
1116
22
  /** Key of the option */
1117
23
  /** Description of the option */
@@ -1164,7 +70,7 @@ type CoreInterface<V = string> = {
1164
70
  };
1165
71
  declare class Core<Config extends OptionSuper = OptionCommon, V = string> {
1166
72
  config: Prettify<Config>;
1167
- _utils: typeof __utils;
73
+ _utils: OptionsUtils;
1168
74
  /** On cancel callback */
1169
75
  _onCancel: () => Promise<void>;
1170
76
  /** After the prompt is set */
@@ -1185,7 +91,7 @@ declare class Core<Config extends OptionSuper = OptionCommon, V = string> {
1185
91
  readonly array: "array";
1186
92
  readonly choices: "choices";
1187
93
  };
1188
- constructor(config: Prettify<Config>);
94
+ constructor(config: Prettify<Config>, _utils: OptionsUtils);
1189
95
  protected _text: {
1190
96
  initialValueSuccess: (t: string, v: string) => string;
1191
97
  initialValueError: (v?: string) => string;
@@ -1249,7 +155,8 @@ declare const TEXT_EDITOR: {
1249
155
  type TextEditor = ObjectValues<typeof TEXT_EDITOR>;
1250
156
  type OptionEditor = SelectBaseOptions<TextEditor>;
1251
157
  declare class Editor extends Select<TextEditor> {
1252
- constructor(config: OptionEditor);
158
+ _utils: OptionsUtils;
159
+ constructor(config: OptionEditor, _utils: OptionsUtils);
1253
160
  validateInitialValue(data?: {
1254
161
  showSuccess?: boolean;
1255
162
  showError?: boolean;
@@ -1269,7 +176,8 @@ declare const INSTALLER: {
1269
176
  type Installer = ObjectValues<typeof INSTALLER>;
1270
177
  type OptionInstall = SelectBaseOptions<Installer>;
1271
178
  declare class Install extends Select<Installer> {
1272
- constructor(config: OptionInstall);
179
+ _utils: OptionsUtils;
180
+ constructor(config: OptionInstall, _utils: OptionsUtils);
1273
181
  validateInitialValue(data?: {
1274
182
  showSuccess?: boolean;
1275
183
  showError?: boolean;
@@ -1303,13 +211,13 @@ type OptionArray = OptionCommonWithPlaceholder<Value$4> & {
1303
211
  */
1304
212
  separator?: string;
1305
213
  };
1306
- declare class Array$1 extends Core<OptionArray, Value$4> implements CoreInterface<Value$4> {
214
+ declare class Array extends Core<OptionArray, Value$4> implements CoreInterface<Value$4> {
1307
215
  #private;
1308
216
  cmd(): Promise<CliOption>;
1309
217
  validateInitialValue(data?: {
1310
218
  showSuccess?: boolean;
1311
219
  showError?: boolean;
1312
- }): Promise<Value$4 | undefined>;
220
+ }): Promise<string[] | undefined>;
1313
221
  prompt(): Promise<string[]>;
1314
222
  }
1315
223
 
@@ -1378,7 +286,8 @@ declare class Void extends Core<OptionVoid, void> implements CoreInterface<void>
1378
286
 
1379
287
  type OptionName = Partial<Name['config']>;
1380
288
  declare class Name extends Text {
1381
- constructor(config: OptionName);
289
+ _utils: OptionsUtils;
290
+ constructor(config: OptionName, _utils: OptionsUtils);
1382
291
  validateInitialValue(data?: {
1383
292
  showSuccess?: boolean;
1384
293
  showError?: boolean;
@@ -1407,7 +316,8 @@ type OptionPath = Partial<Path['config']> & {
1407
316
  };
1408
317
  declare class Path extends Text {
1409
318
  #private;
1410
- constructor(config: OptionPath);
319
+ _utils: OptionsUtils;
320
+ constructor(config: OptionPath, _utils: OptionsUtils);
1411
321
  validateInitialValue(data?: {
1412
322
  showSuccess?: boolean;
1413
323
  showError?: boolean;
@@ -1417,7 +327,8 @@ declare class Path extends Text {
1417
327
 
1418
328
  type OptionOutput = Partial<Omit<Path['config'], 'pathType' | 'exists'>>;
1419
329
  declare class Output extends Path {
1420
- constructor(config: OptionOutput);
330
+ _utils: OptionsUtils;
331
+ constructor(config: OptionOutput, _utils: OptionsUtils);
1421
332
  }
1422
333
 
1423
334
  type OptionTemplate = Partial<Omit<Select['config'], 'options'>> & {
@@ -1441,7 +352,8 @@ type OptionTemplate = Partial<Omit<Select['config'], 'options'>> & {
1441
352
  };
1442
353
  };
1443
354
  declare class Template extends Select<keyof OptionTemplate['options']> {
1444
- constructor(config: OptionTemplate);
355
+ _utils: OptionsUtils;
356
+ constructor(config: OptionTemplate, _utils: OptionsUtils);
1445
357
  }
1446
358
 
1447
359
  type Options = {
@@ -1475,7 +387,7 @@ type Options = {
1475
387
  };
1476
388
  type OptionsClasses = {
1477
389
  /** Class for handling array options */
1478
- [OPTION.array]: typeof Array$1;
390
+ [OPTION.array]: typeof Array;
1479
391
  /** Class for handling select options */
1480
392
  [OPTION.select]: typeof Select;
1481
393
  /** Class for handling multiselect options */
@@ -1656,7 +568,7 @@ type GetPromptValues<C extends Config> = Prettify<{
1656
568
  */
1657
569
  declare class CreatiumCore<C extends Config = Config> {
1658
570
  #private;
1659
- utils: typeof __utils;
571
+ utils: OptionsUtils;
1660
572
  config: C;
1661
573
  constructor(config: C);
1662
574
  /** Force debug mode */
@@ -1965,5 +877,5 @@ declare class Creatium {
1965
877
  }>;
1966
878
  }
1967
879
 
1968
- export { Creatium, CreatiumCore, INSTALLER, OPTION, TEXT_EDITOR, arePathsEqual, box, cache, catchExecOutput, color, columns, copyDir, copyFile, createDir, createSymlink, ensureDir, env, exec, execChild, existsDir, existsFile, existsLocalBin, existsLocalBins, existsPath, getAbsolutePath, getArch, getBaseName, getClosestPackageDir, getClosestPackageJson, getContentDir, getCurrentDir, getDirName, getExtName, getFilteredFileNames, getHomeDir, getObjectFromJSONFile, getPaths, getPlatform, getStringType, getSystemEnvPaths, getTempDir, gradient, isAbsolutePath, isBrowser, isBun, isDeno, isDev, isDirectory, isJsDom, isNode, isPath, isWebWorker, joinPath, joinUrl, line, normalizePath, object2string, prompt, readDir, readFile, relativePath, removeDir, removeDirIfExist, removeFile, removeFileIfExist, removePathIfExist, replacePlaceholders, resolvePath, table, truncate, validateHomeDir, writeFile, writeFileContent };
1969
- export type { Any, AnyArray, AssertEqual, CliOpts, CommonObj, Config, ContentInput, CopyDirOptions, CreateOpts, CreateTemplateOpts, DeepNonNullable, DeepPartial, DeepRequired, EmptyObject, ExpectEqual, FunctionKeys, GetResponse, NonFunctionKeys, NonUndefined, ObjectKeys, ObjectToArray, ObjectValues, Prettify, Response, ReturnAwaitedType, SingleChar };
880
+ export { Creatium, CreatiumCore, INSTALLER, OPTION, TEXT_EDITOR };
881
+ export type { CliOpts, Config, CreateOpts, CreateTemplateOpts };