js-utils-kit 0.0.0 → 0.2.0
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/LICENSE +20 -20
- package/README.md +153 -3
- package/dist/char/index.cjs +1 -0
- package/dist/char/index.d.ts +41 -0
- package/dist/char/index.js +1 -0
- package/dist/cli/index.js +50 -0
- package/dist/env/index.cjs +1 -0
- package/dist/env/index.d.ts +128 -0
- package/dist/env/index.js +1 -0
- package/dist/file/index.cjs +49 -0
- package/dist/file/index.d.ts +75 -0
- package/dist/file/index.js +49 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/number/index.cjs +1 -0
- package/dist/number/index.d.ts +74 -0
- package/dist/number/index.js +1 -0
- package/dist/object/index.cjs +1 -0
- package/dist/object/index.d.ts +46 -0
- package/dist/object/index.js +1 -0
- package/dist/string/index.cjs +1 -0
- package/dist/string/index.d.ts +137 -0
- package/dist/string/index.js +1 -0
- package/package.json +110 -72
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ArchiverOptions } from 'archiver';
|
|
2
|
+
export { ArchiverOptions } from 'archiver';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Supported archive formats.
|
|
6
|
+
*/
|
|
7
|
+
type ArchiveFormat = 'zip' | 'tar';
|
|
8
|
+
/**
|
|
9
|
+
* Configuration options.
|
|
10
|
+
*/
|
|
11
|
+
interface CreateArchiveOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Archive format to use {@link ArchiveFormat}.
|
|
14
|
+
*/
|
|
15
|
+
format: ArchiveFormat;
|
|
16
|
+
/**
|
|
17
|
+
* Path to the source directory that should be archived.
|
|
18
|
+
*/
|
|
19
|
+
source: string;
|
|
20
|
+
/**
|
|
21
|
+
* Destination file path where the archive will be written
|
|
22
|
+
* @example
|
|
23
|
+
* - For `zip` format: `dist.zip`
|
|
24
|
+
* - For `tar` format: `dist.tar`
|
|
25
|
+
*/
|
|
26
|
+
destination: string;
|
|
27
|
+
/**
|
|
28
|
+
* Additional options passed directly to the archiver library. See {@link ArchiverOptions}.
|
|
29
|
+
*/
|
|
30
|
+
options?: ArchiverOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Optional flag to enable internal logging. Useful for CLI mode.
|
|
33
|
+
*/
|
|
34
|
+
log?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Called after archiving is complete — receives total size in bytes.
|
|
37
|
+
*/
|
|
38
|
+
onSuccess?: (bytes: number) => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a {@link ArchiveFormat } archive from a specified directory.
|
|
42
|
+
*
|
|
43
|
+
* This function uses the `archiver` library to package a directory into an archive file.
|
|
44
|
+
* It supports optional compression for `zip` and returns a Promise that resolves
|
|
45
|
+
* when the archive is successfully created.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
*
|
|
49
|
+
* Function usage:
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* await createArchive({
|
|
53
|
+
* format: "zip",
|
|
54
|
+
* source: "dist/",
|
|
55
|
+
* destination: "dist.zip",
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* CLI usage:
|
|
60
|
+
* ```sh
|
|
61
|
+
* npx js-utils-kit createArchive -f zip -s dist -d dist.zip
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param options - Archive creation options
|
|
65
|
+
* @returns A Promise that resolves when the archive is created
|
|
66
|
+
* @throws If an error occurs during the archiving process
|
|
67
|
+
*/
|
|
68
|
+
declare function createArchive({ format, source, destination, options, log, onSuccess, }: CreateArchiveOptions): Promise<void>;
|
|
69
|
+
|
|
70
|
+
declare const _default: {
|
|
71
|
+
createArchive: typeof createArchive;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { createArchive, _default as default };
|
|
75
|
+
export type { ArchiveFormat, CreateArchiveOptions };
|