@js-utils-kit/fs 1.0.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 +21 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.mts +38 -0
- package/dist/index.mjs +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sriman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`fs`);c=s(c);let l=require(`path`);l=s(l);let u=require(`archiver`);u=s(u);function d({format:e,source:t,destination:n,options:r={},log:i=!0,onSuccess:a}){let o=l.default.resolve(t);if(!c.default.existsSync(o)||!c.default.statSync(o).isDirectory())throw Error(`Source directory "${t}" does not exist or is not a directory.`);let s=c.default.createWriteStream(n);e===`zip`&&(r={...r,zlib:{level:9}});let d=(0,u.default)(e,r);return new Promise((e,r)=>{s.on(`close`,()=>{let t=d.pointer();i&&console.log(`${n} created: ${t} total bytes`),a&&a(t),e()}),d.on(`error`,e=>{r(e)}),d.pipe(s),d.directory(t,!1),d.finalize().catch(e=>r(e instanceof Error?e:Error(String(e))))})}exports.createArchive=d;var f=require(`@js-utils-kit/types`);Object.keys(f).forEach(function(e){e!==`default`&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return f[e]}})});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CreateArchiveOptions } from "@js-utils-kit/types";
|
|
2
|
+
export * from "@js-utils-kit/types";
|
|
3
|
+
|
|
4
|
+
//#region src/createArchive.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a {@link ArchiveFormat } archive from a specified directory.
|
|
8
|
+
*
|
|
9
|
+
* This function uses the `archiver` library to package a directory into an archive file.
|
|
10
|
+
* It supports optional compression for `zip` and returns a Promise that resolves
|
|
11
|
+
* when the archive is successfully created.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* Function usage:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* await createArchive({
|
|
19
|
+
* format: "zip",
|
|
20
|
+
* source: "dist/",
|
|
21
|
+
* destination: "dist.zip",
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @returns A Promise that resolves when the archive is created
|
|
26
|
+
*
|
|
27
|
+
* @throws If an error occurs during the archiving process
|
|
28
|
+
*/
|
|
29
|
+
declare function createArchive({
|
|
30
|
+
format,
|
|
31
|
+
source,
|
|
32
|
+
destination,
|
|
33
|
+
options,
|
|
34
|
+
log,
|
|
35
|
+
onSuccess
|
|
36
|
+
}: CreateArchiveOptions): Promise<void>;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { createArchive };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CreateArchiveOptions } from "@js-utils-kit/types";
|
|
2
|
+
export * from "@js-utils-kit/types";
|
|
3
|
+
|
|
4
|
+
//#region src/createArchive.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates a {@link ArchiveFormat } archive from a specified directory.
|
|
8
|
+
*
|
|
9
|
+
* This function uses the `archiver` library to package a directory into an archive file.
|
|
10
|
+
* It supports optional compression for `zip` and returns a Promise that resolves
|
|
11
|
+
* when the archive is successfully created.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* Function usage:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* await createArchive({
|
|
19
|
+
* format: "zip",
|
|
20
|
+
* source: "dist/",
|
|
21
|
+
* destination: "dist.zip",
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @returns A Promise that resolves when the archive is created
|
|
26
|
+
*
|
|
27
|
+
* @throws If an error occurs during the archiving process
|
|
28
|
+
*/
|
|
29
|
+
declare function createArchive({
|
|
30
|
+
format,
|
|
31
|
+
source,
|
|
32
|
+
destination,
|
|
33
|
+
options,
|
|
34
|
+
log,
|
|
35
|
+
onSuccess
|
|
36
|
+
}: CreateArchiveOptions): Promise<void>;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { createArchive };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"fs";import t from"path";import n from"archiver";export*from"@js-utils-kit/types";function r({format:r,source:i,destination:a,options:o={},log:s=!0,onSuccess:c}){let l=t.resolve(i);if(!e.existsSync(l)||!e.statSync(l).isDirectory())throw Error(`Source directory "${i}" does not exist or is not a directory.`);let u=e.createWriteStream(a);r===`zip`&&(o={...o,zlib:{level:9}});let d=n(r,o);return new Promise((e,t)=>{u.on(`close`,()=>{let t=d.pointer();s&&console.log(`${a} created: ${t} total bytes`),c&&c(t),e()}),d.on(`error`,e=>{t(e)}),d.pipe(u),d.directory(i,!1),d.finalize().catch(e=>t(e instanceof Error?e:Error(String(e))))})}export{r as createArchive};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@js-utils-kit/fs",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "File system utilities",
|
|
5
|
+
"private": false,
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Sriman",
|
|
9
|
+
"email": "136729116+TenEplaysOfficial@users.noreply.github.com",
|
|
10
|
+
"url": "https://tene.vercel.app"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://js-utils.js.org",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/teneplaysofficial/js-utils-kit",
|
|
16
|
+
"directory": "packages/fs"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/teneplaysofficial/js-utils-kit/issues"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.cjs",
|
|
29
|
+
"module": "./dist/index.mjs",
|
|
30
|
+
"types": "./dist/index.d.cts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"import": "./dist/index.mjs",
|
|
34
|
+
"require": "./dist/index.cjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"archiver": "^7.0.1",
|
|
39
|
+
"@js-utils-kit/types": "1.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsdown",
|
|
43
|
+
"test": "vitest run"
|
|
44
|
+
}
|
|
45
|
+
}
|