soda-nodejs 0.5.4 → 0.6.1
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/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/utils/compress.d.ts +11 -0
- package/dist/cjs/utils/compress.js +53 -0
- package/dist/cjs/utils/compress.js.map +7 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/compress.d.ts +11 -0
- package/dist/esm/utils/compress.js +30 -0
- package/dist/esm/utils/compress.js.map +1 -0
- package/package.json +2 -1
- package/src/index.ts +1 -0
- package/src/utils/compress.ts +37 -0
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
// src/index.ts
|
|
17
17
|
var src_exports = {};
|
|
18
18
|
module.exports = __toCommonJS(src_exports);
|
|
19
|
+
__reExport(src_exports, require("./utils/compress"), module.exports);
|
|
19
20
|
__reExport(src_exports, require("./utils/copy"), module.exports);
|
|
20
21
|
__reExport(src_exports, require("./utils/execAsync"), module.exports);
|
|
21
22
|
__reExport(src_exports, require("./utils/saveFile"), module.exports);
|
|
@@ -25,6 +26,7 @@ __reExport(src_exports, require("./utils/unzip"), module.exports);
|
|
|
25
26
|
__reExport(src_exports, require("./utils/zip"), module.exports);
|
|
26
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
28
|
0 && (module.exports = {
|
|
29
|
+
...require("./utils/compress"),
|
|
28
30
|
...require("./utils/copy"),
|
|
29
31
|
...require("./utils/execAsync"),
|
|
30
32
|
...require("./utils/saveFile"),
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"@/utils/copy\"\nexport * from \"@/utils/execAsync\"\nexport * from \"@/utils/saveFile\"\nexport * from \"@/utils/saveResponse\"\nexport * from \"@/utils/spawnAsync\"\nexport * from \"@/utils/unzip\"\nexport * from \"@/utils/zip\"\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,
|
|
4
|
+
"sourcesContent": ["export * from \"@/utils/compress\"\nexport * from \"@/utils/copy\"\nexport * from \"@/utils/execAsync\"\nexport * from \"@/utils/saveFile\"\nexport * from \"@/utils/saveResponse\"\nexport * from \"@/utils/spawnAsync\"\nexport * from \"@/utils/unzip\"\nexport * from \"@/utils/zip\"\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,6BAAd;AACA,wBAAc,yBADd;AAEA,wBAAc,8BAFd;AAGA,wBAAc,6BAHd;AAIA,wBAAc,iCAJd;AAKA,wBAAc,+BALd;AAMA,wBAAc,0BANd;AAOA,wBAAc,wBAPd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/compress.ts
|
|
20
|
+
var compress_exports = {};
|
|
21
|
+
__export(compress_exports, {
|
|
22
|
+
compress: () => compress
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(compress_exports);
|
|
25
|
+
var import_fs = require("fs");
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
var import_tar = require("tar");
|
|
28
|
+
async function compress({ input, output }) {
|
|
29
|
+
input = (0, import_path.resolve)(input);
|
|
30
|
+
if (!(0, import_fs.existsSync)(input))
|
|
31
|
+
throw new Error("Source folder does not exist");
|
|
32
|
+
const outputDir = (0, import_path.dirname)(output);
|
|
33
|
+
if (!(0, import_fs.existsSync)(outputDir))
|
|
34
|
+
(0, import_fs.mkdirSync)(outputDir, { recursive: true });
|
|
35
|
+
await (0, import_tar.create)(
|
|
36
|
+
{
|
|
37
|
+
gzip: true,
|
|
38
|
+
// 使用 gzip 压缩
|
|
39
|
+
file: output,
|
|
40
|
+
// 输出文件路径
|
|
41
|
+
cwd: (0, import_path.dirname)(input)
|
|
42
|
+
// 设置工作目录
|
|
43
|
+
},
|
|
44
|
+
[(0, import_path.basename)(input)]
|
|
45
|
+
// 要压缩的文件夹名
|
|
46
|
+
);
|
|
47
|
+
return (0, import_path.resolve)(output);
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
compress
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=compress.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/compress.ts"],
|
|
4
|
+
"sourcesContent": ["import { existsSync, mkdirSync } from \"fs\"\nimport { basename, dirname, resolve } from \"path\"\nimport { create } from \"tar\"\n\nexport interface CompressionParams {\n /**\n * 需要压缩的文件夹\n */\n input: string\n /**\n * 压缩后的文件路径\n */\n output: string\n}\n\nexport async function compress({ input, output }: CompressionParams) {\n input = resolve(input)\n\n // 确保源路径存在\n if (!existsSync(input)) throw new Error(\"Source folder does not exist\")\n\n // 确保输出目录存在\n const outputDir = dirname(output)\n if (!existsSync(outputDir)) mkdirSync(outputDir, { recursive: true })\n\n // 执行压缩\n await create(\n {\n gzip: true, // 使用 gzip 压缩\n file: output, // 输出文件路径\n cwd: dirname(input), // 设置工作目录\n },\n [basename(input)], // 要压缩的文件夹名\n )\n\n return resolve(output)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAsC;AACtC,kBAA2C;AAC3C,iBAAuB;AAavB,eAAsB,SAAS,EAAE,OAAO,OAAO,GAAsB;AACjE,cAAQ,qBAAQ,KAAK;AAGrB,MAAI,KAAC,sBAAW,KAAK;AAAG,UAAM,IAAI,MAAM,8BAA8B;AAGtE,QAAM,gBAAY,qBAAQ,MAAM;AAChC,MAAI,KAAC,sBAAW,SAAS;AAAG,6BAAU,WAAW,EAAE,WAAW,KAAK,CAAC;AAGpE,YAAM;AAAA,IACF;AAAA,MACI,MAAM;AAAA;AAAA,MACN,MAAM;AAAA;AAAA,MACN,SAAK,qBAAQ,KAAK;AAAA;AAAA,IACtB;AAAA,IACA,KAAC,sBAAS,KAAK,CAAC;AAAA;AAAA,EACpB;AAEA,aAAO,qBAAQ,MAAM;AACzB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"@/utils/copy\"\nexport * from \"@/utils/execAsync\"\nexport * from \"@/utils/saveFile\"\nexport * from \"@/utils/saveResponse\"\nexport * from \"@/utils/spawnAsync\"\nexport * from \"@/utils/unzip\"\nexport * from \"@/utils/zip\"\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"@/utils/compress\"\nexport * from \"@/utils/copy\"\nexport * from \"@/utils/execAsync\"\nexport * from \"@/utils/saveFile\"\nexport * from \"@/utils/saveResponse\"\nexport * from \"@/utils/spawnAsync\"\nexport * from \"@/utils/unzip\"\nexport * from \"@/utils/zip\"\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from "fs";
|
|
2
|
+
import { basename, dirname, resolve } from "path";
|
|
3
|
+
import { create } from "tar";
|
|
4
|
+
export async function compress({
|
|
5
|
+
input,
|
|
6
|
+
output
|
|
7
|
+
}) {
|
|
8
|
+
input = resolve(input);
|
|
9
|
+
|
|
10
|
+
// 确保源路径存在
|
|
11
|
+
if (!existsSync(input)) throw new Error("Source folder does not exist");
|
|
12
|
+
|
|
13
|
+
// 确保输出目录存在
|
|
14
|
+
const outputDir = dirname(output);
|
|
15
|
+
if (!existsSync(outputDir)) mkdirSync(outputDir, {
|
|
16
|
+
recursive: true
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// 执行压缩
|
|
20
|
+
await create({
|
|
21
|
+
gzip: true,
|
|
22
|
+
// 使用 gzip 压缩
|
|
23
|
+
file: output,
|
|
24
|
+
// 输出文件路径
|
|
25
|
+
cwd: dirname(input) // 设置工作目录
|
|
26
|
+
}, [basename(input)] // 要压缩的文件夹名
|
|
27
|
+
);
|
|
28
|
+
return resolve(output);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=compress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["existsSync","mkdirSync","basename","dirname","resolve","create","compress","input","output","Error","outputDir","recursive","gzip","file","cwd"],"sources":["../../../src/utils/compress.ts"],"sourcesContent":["import { existsSync, mkdirSync } from \"fs\"\nimport { basename, dirname, resolve } from \"path\"\nimport { create } from \"tar\"\n\nexport interface CompressionParams {\n /**\n * 需要压缩的文件夹\n */\n input: string\n /**\n * 压缩后的文件路径\n */\n output: string\n}\n\nexport async function compress({ input, output }: CompressionParams) {\n input = resolve(input)\n\n // 确保源路径存在\n if (!existsSync(input)) throw new Error(\"Source folder does not exist\")\n\n // 确保输出目录存在\n const outputDir = dirname(output)\n if (!existsSync(outputDir)) mkdirSync(outputDir, { recursive: true })\n\n // 执行压缩\n await create(\n {\n gzip: true, // 使用 gzip 压缩\n file: output, // 输出文件路径\n cwd: dirname(input), // 设置工作目录\n },\n [basename(input)], // 要压缩的文件夹名\n )\n\n return resolve(output)\n}\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,SAAS,QAAQ,IAAI;AAC1C,SAASC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,QAAQ,MAAM;AACjD,SAASC,MAAM,QAAQ,KAAK;AAa5B,OAAO,eAAeC,QAAQA,CAAC;EAAEC,KAAK;EAAEC;AAA0B,CAAC,EAAE;EACjED,KAAK,GAAGH,OAAO,CAACG,KAAK,CAAC;;EAEtB;EACA,IAAI,CAACP,UAAU,CAACO,KAAK,CAAC,EAAE,MAAM,IAAIE,KAAK,CAAC,8BAA8B,CAAC;;EAEvE;EACA,MAAMC,SAAS,GAAGP,OAAO,CAACK,MAAM,CAAC;EACjC,IAAI,CAACR,UAAU,CAACU,SAAS,CAAC,EAAET,SAAS,CAACS,SAAS,EAAE;IAAEC,SAAS,EAAE;EAAK,CAAC,CAAC;;EAErE;EACA,MAAMN,MAAM,CACR;IACIO,IAAI,EAAE,IAAI;IAAE;IACZC,IAAI,EAAEL,MAAM;IAAE;IACdM,GAAG,EAAEX,OAAO,CAACI,KAAK,CAAC,CAAE;EACzB,CAAC,EACD,CAACL,QAAQ,CAACK,KAAK,CAAC,CAAC,CAAE;EACvB,CAAC;EAED,OAAOH,OAAO,CAACI,MAAM,CAAC;AAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soda-nodejs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"iconv-lite": "^0.6.3",
|
|
31
|
+
"tar": "^7.4.3",
|
|
31
32
|
"which": "^4.0.0"
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from "fs"
|
|
2
|
+
import { basename, dirname, resolve } from "path"
|
|
3
|
+
import { create } from "tar"
|
|
4
|
+
|
|
5
|
+
export interface CompressionParams {
|
|
6
|
+
/**
|
|
7
|
+
* 需要压缩的文件夹
|
|
8
|
+
*/
|
|
9
|
+
input: string
|
|
10
|
+
/**
|
|
11
|
+
* 压缩后的文件路径
|
|
12
|
+
*/
|
|
13
|
+
output: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function compress({ input, output }: CompressionParams) {
|
|
17
|
+
input = resolve(input)
|
|
18
|
+
|
|
19
|
+
// 确保源路径存在
|
|
20
|
+
if (!existsSync(input)) throw new Error("Source folder does not exist")
|
|
21
|
+
|
|
22
|
+
// 确保输出目录存在
|
|
23
|
+
const outputDir = dirname(output)
|
|
24
|
+
if (!existsSync(outputDir)) mkdirSync(outputDir, { recursive: true })
|
|
25
|
+
|
|
26
|
+
// 执行压缩
|
|
27
|
+
await create(
|
|
28
|
+
{
|
|
29
|
+
gzip: true, // 使用 gzip 压缩
|
|
30
|
+
file: output, // 输出文件路径
|
|
31
|
+
cwd: dirname(input), // 设置工作目录
|
|
32
|
+
},
|
|
33
|
+
[basename(input)], // 要压缩的文件夹名
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
return resolve(output)
|
|
37
|
+
}
|