soda-nodejs 0.6.5 → 0.7.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/dist/index.cjs +123 -0
- package/dist/index.js +8 -0
- package/dist/utils/compress.cjs +54 -0
- package/dist/utils/compress.js +20 -0
- package/dist/utils/copy.cjs +70 -0
- package/dist/utils/copy.js +36 -0
- package/dist/utils/execAsync.cjs +61 -0
- package/dist/{esm/utils → utils}/execAsync.d.ts +0 -4
- package/dist/utils/execAsync.js +17 -0
- package/dist/utils/saveFile.cjs +43 -0
- package/dist/utils/saveFile.js +9 -0
- package/dist/utils/saveResponse.cjs +41 -0
- package/dist/utils/saveResponse.js +7 -0
- package/dist/utils/spawnAsync.cjs +78 -0
- package/dist/{cjs/utils → utils}/spawnAsync.d.ts +0 -2
- package/dist/utils/spawnAsync.js +38 -0
- package/dist/utils/unzip.cjs +53 -0
- package/dist/utils/unzip.js +9 -0
- package/dist/utils/zip.cjs +56 -0
- package/dist/utils/zip.js +12 -0
- package/package.json +26 -13
- package/tsconfig.json +15 -0
- package/dist/cjs/index.js +0 -38
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/utils/compress.js +0 -53
- package/dist/cjs/utils/compress.js.map +0 -7
- package/dist/cjs/utils/copy.js +0 -58
- package/dist/cjs/utils/copy.js.map +0 -7
- package/dist/cjs/utils/execAsync.d.ts +0 -36
- package/dist/cjs/utils/execAsync.js +0 -57
- package/dist/cjs/utils/execAsync.js.map +0 -7
- package/dist/cjs/utils/saveFile.js +0 -37
- package/dist/cjs/utils/saveFile.js.map +0 -7
- package/dist/cjs/utils/saveResponse.js +0 -37
- package/dist/cjs/utils/saveResponse.js.map +0 -7
- package/dist/cjs/utils/spawnAsync.js +0 -69
- package/dist/cjs/utils/spawnAsync.js.map +0 -7
- package/dist/cjs/utils/unzip.js +0 -45
- package/dist/cjs/utils/unzip.js.map +0 -7
- package/dist/cjs/utils/zip.js +0 -52
- package/dist/cjs/utils/zip.js.map +0 -7
- package/dist/esm/index.d.ts +0 -8
- package/dist/esm/index.js +0 -9
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/utils/compress.d.ts +0 -11
- package/dist/esm/utils/compress.js +0 -30
- package/dist/esm/utils/compress.js.map +0 -1
- package/dist/esm/utils/copy.d.ts +0 -9
- package/dist/esm/utils/copy.js +0 -44
- package/dist/esm/utils/copy.js.map +0 -1
- package/dist/esm/utils/execAsync.js +0 -21
- package/dist/esm/utils/execAsync.js.map +0 -1
- package/dist/esm/utils/saveFile.d.ts +0 -10
- package/dist/esm/utils/saveFile.js +0 -15
- package/dist/esm/utils/saveFile.js.map +0 -1
- package/dist/esm/utils/saveResponse.d.ts +0 -6
- package/dist/esm/utils/saveResponse.js +0 -13
- package/dist/esm/utils/saveResponse.js.map +0 -1
- package/dist/esm/utils/spawnAsync.d.ts +0 -38
- package/dist/esm/utils/spawnAsync.js +0 -52
- package/dist/esm/utils/spawnAsync.js.map +0 -1
- package/dist/esm/utils/unzip.d.ts +0 -26
- package/dist/esm/utils/unzip.js +0 -24
- package/dist/esm/utils/unzip.js.map +0 -1
- package/dist/esm/utils/zip.d.ts +0 -38
- package/dist/esm/utils/zip.js +0 -30
- package/dist/esm/utils/zip.js.map +0 -1
- /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
- /package/dist/{cjs/utils → utils}/compress.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/copy.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/saveFile.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/saveResponse.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/unzip.d.ts +0 -0
- /package/dist/{cjs/utils → utils}/zip.d.ts +0 -0
|
@@ -1,69 +0,0 @@
|
|
|
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/spawnAsync.ts
|
|
20
|
-
var spawnAsync_exports = {};
|
|
21
|
-
__export(spawnAsync_exports, {
|
|
22
|
-
getDefaultOptions: () => getDefaultOptions,
|
|
23
|
-
setDefaultOptions: () => setDefaultOptions,
|
|
24
|
-
spawnAsync: () => spawnAsync
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(spawnAsync_exports);
|
|
27
|
-
var import_child_process = require("child_process");
|
|
28
|
-
var defaultOptions = {};
|
|
29
|
-
function getDefaultOptions() {
|
|
30
|
-
return defaultOptions;
|
|
31
|
-
}
|
|
32
|
-
function setDefaultOptions(options) {
|
|
33
|
-
if (typeof options === "function") {
|
|
34
|
-
defaultOptions = options(defaultOptions);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
defaultOptions = options;
|
|
38
|
-
return defaultOptions;
|
|
39
|
-
}
|
|
40
|
-
function spawnAsync(command, args, options) {
|
|
41
|
-
let child;
|
|
42
|
-
const promise = new Promise((resolve, reject) => {
|
|
43
|
-
if (Array.isArray(args))
|
|
44
|
-
options = { ...defaultOptions, ...options };
|
|
45
|
-
else
|
|
46
|
-
args = { ...defaultOptions, ...args };
|
|
47
|
-
child = (0, import_child_process.spawn)(command, args, options);
|
|
48
|
-
child.on("exit", (code) => {
|
|
49
|
-
if (code === 0)
|
|
50
|
-
return resolve(child);
|
|
51
|
-
if (Array.isArray(args)) {
|
|
52
|
-
const args2 = args.map((item) => item.trim()).filter(Boolean);
|
|
53
|
-
if (args2.length > 0)
|
|
54
|
-
command = `${command} ${args2.join(" ")}`;
|
|
55
|
-
}
|
|
56
|
-
reject(new Error(`spawn "${command}" failed with code ${code}`));
|
|
57
|
-
return;
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
promise.child = child;
|
|
61
|
-
return promise;
|
|
62
|
-
}
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
getDefaultOptions,
|
|
66
|
-
setDefaultOptions,
|
|
67
|
-
spawnAsync
|
|
68
|
-
});
|
|
69
|
-
//# sourceMappingURL=spawnAsync.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/utils/spawnAsync.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n ChildProcess,\n ChildProcessByStdio,\n ChildProcessWithoutNullStreams,\n SpawnOptions,\n SpawnOptionsWithStdioTuple,\n SpawnOptionsWithoutStdio,\n StdioNull,\n StdioPipe,\n spawn,\n} from \"child_process\"\nimport { Readable, Writable } from \"stream\"\n\nexport interface PromiseWithChildProcess<T> extends Promise<T> {\n child: T\n}\n\nexport type Options =\n | SpawnOptionsWithoutStdio\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n | SpawnOptions\n\nlet defaultOptions: Options = {}\n\n/**\n * @description get default options for spawnAsync\n * @returns {Options} options\n */\nexport function getDefaultOptions(): Options {\n return defaultOptions\n}\n\n/**\n * @description set default options for spawnAsync\n * @param {Options | ((prev: Options) => Options)} options\n */\nexport function setDefaultOptions(options: Options | ((prev: Options) => Options)) {\n if (typeof options === \"function\") {\n defaultOptions = options(defaultOptions)\n return\n }\n defaultOptions = options\n return defaultOptions\n}\n\nexport function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>\nexport function spawnAsync(command: string, options: SpawnOptions): PromiseWithChildProcess<ChildProcess>\nexport function spawnAsync(\n command: string,\n args?: readonly string[],\n options?: SpawnOptionsWithoutStdio,\n): PromiseWithChildProcess<ChildProcessWithoutNullStreams>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): PromiseWithChildProcess<ChildProcess>\n\n/**\n * @description wait for the command to exit\n * @returns a promise that resolves with the child process when the command exits successfully. Also, the child process is attached to the promise as a property.\n */\nexport function spawnAsync(command: string, args?: any, options?: any): Promise<any> {\n let child: any\n const promise = new Promise<any>((resolve, reject) => {\n if (Array.isArray(args)) options = { ...defaultOptions, ...options }\n else args = { ...defaultOptions, ...args }\n child = spawn(command, args, options)\n child.on(\"exit\", (code: number) => {\n if (code === 0) return resolve(child)\n if (Array.isArray(args)) {\n const args2 = args.map((item: string) => item.trim()).filter(Boolean)\n if (args2.length > 0) command = `${command} ${args2.join(\" \")}`\n }\n reject(new Error(`spawn \"${command}\" failed with code ${code}`))\n return\n })\n }) as PromiseWithChildProcess<any>\n promise.child = child\n return promise\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAUO;AAmBP,IAAI,iBAA0B,CAAC;AAMxB,SAAS,oBAA6B;AACzC,SAAO;AACX;AAMO,SAAS,kBAAkB,SAAiD;AAC/E,MAAI,OAAO,YAAY,YAAY;AAC/B,qBAAiB,QAAQ,cAAc;AACvC;AAAA,EACJ;AACA,mBAAiB;AACjB,SAAO;AACX;AAuFO,SAAS,WAAW,SAAiB,MAAY,SAA6B;AACjF,MAAI;AACJ,QAAM,UAAU,IAAI,QAAa,CAAC,SAAS,WAAW;AAClD,QAAI,MAAM,QAAQ,IAAI;AAAG,gBAAU,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AAAA;AAC9D,aAAO,EAAE,GAAG,gBAAgB,GAAG,KAAK;AACzC,gBAAQ,4BAAM,SAAS,MAAM,OAAO;AACpC,UAAM,GAAG,QAAQ,CAAC,SAAiB;AAC/B,UAAI,SAAS;AAAG,eAAO,QAAQ,KAAK;AACpC,UAAI,MAAM,QAAQ,IAAI,GAAG;AACrB,cAAM,QAAQ,KAAK,IAAI,CAAC,SAAiB,KAAK,KAAK,CAAC,EAAE,OAAO,OAAO;AACpE,YAAI,MAAM,SAAS;AAAG,oBAAU,GAAG,WAAW,MAAM,KAAK,GAAG;AAAA,MAChE;AACA,aAAO,IAAI,MAAM,UAAU,6BAA6B,MAAM,CAAC;AAC/D;AAAA,IACJ,CAAC;AAAA,EACL,CAAC;AACD,UAAQ,QAAQ;AAChB,SAAO;AACX;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/cjs/utils/unzip.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/utils/unzip.ts
|
|
30
|
-
var unzip_exports = {};
|
|
31
|
-
__export(unzip_exports, {
|
|
32
|
-
unzip: () => unzip
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(unzip_exports);
|
|
35
|
-
var import_which = __toESM(require("which"));
|
|
36
|
-
var import_execAsync = require("./execAsync");
|
|
37
|
-
async function unzip({ input, output, cwd }) {
|
|
38
|
-
await (0, import_which.default)("7z");
|
|
39
|
-
return await (0, import_execAsync.execAsync)(`7z x ${input} -o${output}`, { cwd });
|
|
40
|
-
}
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
unzip
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=unzip.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/utils/unzip.ts"],
|
|
4
|
-
"sourcesContent": ["import which from \"which\"\n\nimport { execAsync } from \"./execAsync\"\n\nexport type UnzipOptions = {\n /**\n * 要解压的文件\n */\n input: string\n /**\n * 解压到的目标文件夹位置\n */\n output: string\n /**\n * 压缩文件时的工作目录\n */\n cwd?: string\n}\n\n/**\n * 使用 7z 命令解压文件\n * - 如果没有安装 7z,请先安装 7z 后再执行\n * - 下载地址:https://www.7-zip.org/download.html\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\n * 2. 在系统变量中找到并选中 Path,点击编辑\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\n */\nexport async function unzip({ input, output, cwd }: UnzipOptions) {\n await which(\"7z\")\n return await execAsync(`7z x ${input} -o${output}`, { cwd })\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,uBAA0B;AA4B1B,eAAsB,MAAM,EAAE,OAAO,QAAQ,IAAI,GAAiB;AAC9D,YAAM,aAAAA,SAAM,IAAI;AAChB,SAAO,UAAM,4BAAU,QAAQ,WAAW,UAAU,EAAE,IAAI,CAAC;AAC/D;",
|
|
6
|
-
"names": ["which"]
|
|
7
|
-
}
|
package/dist/cjs/utils/zip.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/utils/zip.ts
|
|
30
|
-
var zip_exports = {};
|
|
31
|
-
__export(zip_exports, {
|
|
32
|
-
zip: () => zip
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(zip_exports);
|
|
35
|
-
var import_os = require("os");
|
|
36
|
-
var import_which = __toESM(require("which"));
|
|
37
|
-
var import_execAsync = require("./execAsync");
|
|
38
|
-
async function zip({ input, output, thread = "auto", level, password, cwd }) {
|
|
39
|
-
await (0, import_which.default)("7z");
|
|
40
|
-
input = Array.isArray(input) ? input.join(" ") : input;
|
|
41
|
-
if (thread === "max")
|
|
42
|
-
thread = (0, import_os.cpus)().length;
|
|
43
|
-
return await (0, import_execAsync.execAsync)(
|
|
44
|
-
`7z a ${output} ${input} -mmt=${thread === "auto" ? "on" : thread}${typeof level === "number" ? ` -mx=${level}` : ""}${password ? ` -p${password}` : ""}`,
|
|
45
|
-
{ cwd }
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
-
0 && (module.exports = {
|
|
50
|
-
zip
|
|
51
|
-
});
|
|
52
|
-
//# sourceMappingURL=zip.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/utils/zip.ts"],
|
|
4
|
-
"sourcesContent": ["import { cpus } from \"os\"\nimport which from \"which\"\n\nimport { execAsync } from \"./execAsync\"\n\nexport type ZipOptions = {\n /**\n * 要压缩的文件\n */\n input: string | string[]\n /**\n * 压缩到的目标位置,文件名的后缀就是压缩格式,例如:.zip、.7z\n */\n output: string\n /**\n * 线程数\n */\n thread?: number | \"auto\" | \"max\"\n /**\n * 压缩等级,0-9\n */\n level?: number\n /**\n * 是否加密\n */\n password?: string\n /**\n * 压缩文件时的工作目录\n */\n cwd?: string\n}\n\n/**\n * 使用 7z 命令压缩文件\n * - 如果没有安装 7z,请先安装 7z 后再执行\n * - 下载地址:https://www.7-zip.org/download.html\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\n * 2. 在系统变量中找到并选中 Path,点击编辑\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\n */\nexport async function zip({ input, output, thread = \"auto\", level, password, cwd }: ZipOptions) {\n await which(\"7z\")\n input = Array.isArray(input) ? input.join(\" \") : input\n if (thread === \"max\") thread = cpus().length\n return await execAsync(\n `7z a ${output} ${input} -mmt=${thread === \"auto\" ? \"on\" : thread}${typeof level === \"number\" ? ` -mx=${level}` : \"\"}${password ? ` -p${password}` : \"\"}`,\n { cwd },\n )\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqB;AACrB,mBAAkB;AAElB,uBAA0B;AAwC1B,eAAsB,IAAI,EAAE,OAAO,QAAQ,SAAS,QAAQ,OAAO,UAAU,IAAI,GAAe;AAC5F,YAAM,aAAAA,SAAM,IAAI;AAChB,UAAQ,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,GAAG,IAAI;AACjD,MAAI,WAAW;AAAO,iBAAS,gBAAK,EAAE;AACtC,SAAO,UAAM;AAAA,IACT,QAAQ,UAAU,cAAc,WAAW,SAAS,OAAO,SAAS,OAAO,UAAU,WAAW,QAAQ,UAAU,KAAK,WAAW,MAAM,aAAa;AAAA,IACrJ,EAAE,IAAI;AAAA,EACV;AACJ;",
|
|
6
|
-
"names": ["which"]
|
|
7
|
-
}
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from "./utils/compress";
|
|
2
|
-
export * from "./utils/copy";
|
|
3
|
-
export * from "./utils/execAsync";
|
|
4
|
-
export * from "./utils/saveFile";
|
|
5
|
-
export * from "./utils/saveResponse";
|
|
6
|
-
export * from "./utils/spawnAsync";
|
|
7
|
-
export * from "./utils/unzip";
|
|
8
|
-
export * from "./utils/zip";
|
package/dist/esm/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./utils/compress";
|
|
2
|
-
export * from "./utils/copy";
|
|
3
|
-
export * from "./utils/execAsync";
|
|
4
|
-
export * from "./utils/saveFile";
|
|
5
|
-
export * from "./utils/saveResponse";
|
|
6
|
-
export * from "./utils/spawnAsync";
|
|
7
|
-
export * from "./utils/unzip";
|
|
8
|
-
export * from "./utils/zip";
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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/dist/esm/utils/copy.d.ts
DELETED
package/dist/esm/utils/copy.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "fs";
|
|
2
|
-
import { copyFile, mkdir, readdir, stat } from "fs/promises";
|
|
3
|
-
import { join, parse } from "path";
|
|
4
|
-
export async function copy({
|
|
5
|
-
input,
|
|
6
|
-
output,
|
|
7
|
-
mode
|
|
8
|
-
}) {
|
|
9
|
-
if (Array.isArray(input)) {
|
|
10
|
-
for (const item of input) await copy({
|
|
11
|
-
input: item,
|
|
12
|
-
output,
|
|
13
|
-
mode
|
|
14
|
-
});
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (!existsSync(output)) await mkdir(output, {
|
|
18
|
-
recursive: true
|
|
19
|
-
});
|
|
20
|
-
const status = await stat(input);
|
|
21
|
-
const {
|
|
22
|
-
base
|
|
23
|
-
} = parse(input);
|
|
24
|
-
if (status.isFile()) {
|
|
25
|
-
await copyFile(input, join(output, base), mode);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (status.isDirectory()) {
|
|
29
|
-
await mkdir(join(output, base), {
|
|
30
|
-
recursive: true
|
|
31
|
-
});
|
|
32
|
-
const entries = await readdir(input, {
|
|
33
|
-
withFileTypes: true
|
|
34
|
-
});
|
|
35
|
-
for (const entry of entries) {
|
|
36
|
-
await copy({
|
|
37
|
-
input: join(input, entry.name),
|
|
38
|
-
output: join(output, base),
|
|
39
|
-
mode
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=copy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["existsSync","copyFile","mkdir","readdir","stat","join","parse","copy","input","output","mode","Array","isArray","item","recursive","status","base","isFile","isDirectory","entries","withFileTypes","entry","name"],"sources":["../../../src/utils/copy.ts"],"sourcesContent":["import { existsSync } from \"fs\"\nimport { copyFile, mkdir, readdir, stat } from \"fs/promises\"\nimport { join, parse } from \"path\"\n\nexport type CopyOptions = {\n /** 源文件夹 */\n input: string | string[]\n /** 存放的文件夹 */\n output: string\n /** 文件权限 */\n mode?: number\n}\n\nexport async function copy({ input, output, mode }: CopyOptions) {\n if (Array.isArray(input)) {\n for (const item of input) await copy({ input: item, output, mode })\n return\n }\n if (!existsSync(output)) await mkdir(output, { recursive: true })\n const status = await stat(input)\n const { base } = parse(input)\n if (status.isFile()) {\n await copyFile(input, join(output, base), mode)\n return\n }\n if (status.isDirectory()) {\n await mkdir(join(output, base), { recursive: true })\n const entries = await readdir(input, { withFileTypes: true })\n for (const entry of entries) {\n await copy({\n input: join(input, entry.name),\n output: join(output, base),\n mode,\n })\n }\n }\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,IAAI;AAC/B,SAASC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAEC,IAAI,QAAQ,aAAa;AAC5D,SAASC,IAAI,EAAEC,KAAK,QAAQ,MAAM;AAWlC,OAAO,eAAeC,IAAIA,CAAC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAkB,CAAC,EAAE;EAC7D,IAAIC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,EAAE;IACtB,KAAK,MAAMK,IAAI,IAAIL,KAAK,EAAE,MAAMD,IAAI,CAAC;MAAEC,KAAK,EAAEK,IAAI;MAAEJ,MAAM;MAAEC;IAAK,CAAC,CAAC;IACnE;EACJ;EACA,IAAI,CAACV,UAAU,CAACS,MAAM,CAAC,EAAE,MAAMP,KAAK,CAACO,MAAM,EAAE;IAAEK,SAAS,EAAE;EAAK,CAAC,CAAC;EACjE,MAAMC,MAAM,GAAG,MAAMX,IAAI,CAACI,KAAK,CAAC;EAChC,MAAM;IAAEQ;EAAK,CAAC,GAAGV,KAAK,CAACE,KAAK,CAAC;EAC7B,IAAIO,MAAM,CAACE,MAAM,CAAC,CAAC,EAAE;IACjB,MAAMhB,QAAQ,CAACO,KAAK,EAAEH,IAAI,CAACI,MAAM,EAAEO,IAAI,CAAC,EAAEN,IAAI,CAAC;IAC/C;EACJ;EACA,IAAIK,MAAM,CAACG,WAAW,CAAC,CAAC,EAAE;IACtB,MAAMhB,KAAK,CAACG,IAAI,CAACI,MAAM,EAAEO,IAAI,CAAC,EAAE;MAAEF,SAAS,EAAE;IAAK,CAAC,CAAC;IACpD,MAAMK,OAAO,GAAG,MAAMhB,OAAO,CAACK,KAAK,EAAE;MAAEY,aAAa,EAAE;IAAK,CAAC,CAAC;IAC7D,KAAK,MAAMC,KAAK,IAAIF,OAAO,EAAE;MACzB,MAAMZ,IAAI,CAAC;QACPC,KAAK,EAAEH,IAAI,CAACG,KAAK,EAAEa,KAAK,CAACC,IAAI,CAAC;QAC9Bb,MAAM,EAAEJ,IAAI,CAACI,MAAM,EAAEO,IAAI,CAAC;QAC1BN;MACJ,CAAC,CAAC;IACN;EACJ;AACJ"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { exec } from "child_process";
|
|
2
|
-
import iconv from "iconv-lite";
|
|
3
|
-
export async function execAsync(command, options) {
|
|
4
|
-
const decode = options?.decode;
|
|
5
|
-
if (typeof options === "object" && options !== null && options.decode) {
|
|
6
|
-
const {
|
|
7
|
-
decode,
|
|
8
|
-
...rest
|
|
9
|
-
} = options;
|
|
10
|
-
options = rest;
|
|
11
|
-
}
|
|
12
|
-
return await new Promise((resolve, reject) => {
|
|
13
|
-
exec(command, options, (error, stdout, stderr) => {
|
|
14
|
-
if (error) return reject(error);
|
|
15
|
-
// if (stderr) console.warn(stderr)
|
|
16
|
-
if (decode && stdout instanceof Buffer) return resolve(iconv.decode(stdout, decode.encoding, decode.options));
|
|
17
|
-
resolve(stdout);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=execAsync.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["exec","iconv","execAsync","command","options","decode","rest","Promise","resolve","reject","error","stdout","stderr","Buffer","encoding"],"sources":["../../../src/utils/execAsync.ts"],"sourcesContent":["import { ExecOptions, exec } from \"child_process\"\nimport { ObjectEncodingOptions } from \"fs\"\nimport iconv, { Options } from \"iconv-lite\"\n\nexport type IconvDecodeOptions = {\n encoding: string\n options?: Options\n}\n\nexport async function execAsync(command: string): Promise<string>\nexport async function execAsync(command: string, options: { encoding: \"buffer\" | null } & ExecOptions): Promise<Buffer>\nexport async function execAsync(command: string, options: { encoding: \"buffer\" | null } & ExecOptions & { decode: IconvDecodeOptions }): Promise<string>\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<string>\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<string | Buffer>\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions & { decode: IconvDecodeOptions }): Promise<string>\nexport async function execAsync(command: string, options: ExecOptions): Promise<string>\nexport async function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<string | Buffer>\nexport async function execAsync(\n command: string,\n options: (ObjectEncodingOptions & ExecOptions & { decode: IconvDecodeOptions }) | undefined | null,\n): Promise<string>\nexport async function execAsync(command: string, options?: any) {\n const decode = options?.decode as IconvDecodeOptions | undefined\n if (typeof options === \"object\" && options !== null && options.decode) {\n const { decode, ...rest } = options as { decode: IconvDecodeOptions }\n options = rest\n }\n return await new Promise<string | Buffer>((resolve, reject) => {\n exec(command, options, (error, stdout, stderr) => {\n if (error) return reject(error)\n // if (stderr) console.warn(stderr)\n if (decode && stdout instanceof Buffer) return resolve(iconv.decode(stdout, decode.encoding, decode.options))\n resolve(stdout)\n })\n })\n}\n"],"mappings":"AAAA,SAAsBA,IAAI,QAAQ,eAAe;AAEjD,OAAOC,KAAK,MAAmB,YAAY;AAmB3C,OAAO,eAAeC,SAASA,CAACC,OAAe,EAAEC,OAAa,EAAE;EAC5D,MAAMC,MAAM,GAAGD,OAAO,EAAEC,MAAwC;EAChE,IAAI,OAAOD,OAAO,KAAK,QAAQ,IAAIA,OAAO,KAAK,IAAI,IAAIA,OAAO,CAACC,MAAM,EAAE;IACnE,MAAM;MAAEA,MAAM;MAAE,GAAGC;IAAK,CAAC,GAAGF,OAAyC;IACrEA,OAAO,GAAGE,IAAI;EAClB;EACA,OAAO,MAAM,IAAIC,OAAO,CAAkB,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC3DT,IAAI,CAACG,OAAO,EAAEC,OAAO,EAAE,CAACM,KAAK,EAAEC,MAAM,EAAEC,MAAM,KAAK;MAC9C,IAAIF,KAAK,EAAE,OAAOD,MAAM,CAACC,KAAK,CAAC;MAC/B;MACA,IAAIL,MAAM,IAAIM,MAAM,YAAYE,MAAM,EAAE,OAAOL,OAAO,CAACP,KAAK,CAACI,MAAM,CAACM,MAAM,EAAEN,MAAM,CAACS,QAAQ,EAAET,MAAM,CAACD,OAAO,CAAC,CAAC;MAC7GI,OAAO,CAACG,MAAM,CAAC;IACnB,CAAC,CAAC;EACN,CAAC,CAAC;AACN"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createWriteStream } from "fs";
|
|
2
|
-
import { Readable } from "stream";
|
|
3
|
-
/**
|
|
4
|
-
* 保存文件
|
|
5
|
-
*/
|
|
6
|
-
export async function saveFile({
|
|
7
|
-
input,
|
|
8
|
-
output
|
|
9
|
-
}) {
|
|
10
|
-
await new Promise((resolve, reject) => {
|
|
11
|
-
const writeAble = createWriteStream(output);
|
|
12
|
-
Readable.fromWeb(input.stream()).pipe(writeAble).on("finish", resolve).on("error", reject);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=saveFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createWriteStream","Readable","saveFile","input","output","Promise","resolve","reject","writeAble","fromWeb","stream","pipe","on"],"sources":["../../../src/utils/saveFile.ts"],"sourcesContent":["import { createWriteStream } from \"fs\"\nimport { Readable } from \"stream\"\n\nexport type SaveFileOptions = {\n /** 要保存的文件 */\n input: File\n /** 保存文件的目标位置 */\n output: string\n}\n\n/**\n * 保存文件\n */\nexport async function saveFile({ input, output }: SaveFileOptions) {\n await new Promise<void>((resolve, reject) => {\n const writeAble = createWriteStream(output)\n Readable.fromWeb(input.stream() as any)\n .pipe(writeAble)\n .on(\"finish\", resolve)\n .on(\"error\", reject)\n })\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,IAAI;AACtC,SAASC,QAAQ,QAAQ,QAAQ;AASjC;AACA;AACA;AACA,OAAO,eAAeC,QAAQA,CAAC;EAAEC,KAAK;EAAEC;AAAwB,CAAC,EAAE;EAC/D,MAAM,IAAIC,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;IACzC,MAAMC,SAAS,GAAGR,iBAAiB,CAACI,MAAM,CAAC;IAC3CH,QAAQ,CAACQ,OAAO,CAACN,KAAK,CAACO,MAAM,CAAC,CAAQ,CAAC,CAClCC,IAAI,CAACH,SAAS,CAAC,CACfI,EAAE,CAAC,QAAQ,EAAEN,OAAO,CAAC,CACrBM,EAAE,CAAC,OAAO,EAAEL,MAAM,CAAC;EAC5B,CAAC,CAAC;AACN"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createWriteStream } from "fs";
|
|
2
|
-
import { Readable } from "stream";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 从 Response 对象中下载文件
|
|
6
|
-
* @param response Response 对象
|
|
7
|
-
* @param file 文件路径
|
|
8
|
-
*/
|
|
9
|
-
export async function saveResponse(response, file) {
|
|
10
|
-
const writeable = createWriteStream(file);
|
|
11
|
-
await new Promise((resolve, reject) => Readable.fromWeb(response.body).pipe(writeable).on("close", resolve).on("error", reject));
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=saveResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createWriteStream","Readable","saveResponse","response","file","writeable","Promise","resolve","reject","fromWeb","body","pipe","on"],"sources":["../../../src/utils/saveResponse.ts"],"sourcesContent":["import { createWriteStream } from \"fs\"\nimport { Readable } from \"stream\"\n\n/**\n * 从 Response 对象中下载文件\n * @param response Response 对象\n * @param file 文件路径\n */\nexport async function saveResponse(response: Response, file: string) {\n const writeable = createWriteStream(file)\n await new Promise<void>((resolve, reject) =>\n Readable.fromWeb(response.body! as any)\n .pipe(writeable)\n .on(\"close\", resolve)\n .on(\"error\", reject),\n )\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,IAAI;AACtC,SAASC,QAAQ,QAAQ,QAAQ;;AAEjC;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAACC,QAAkB,EAAEC,IAAY,EAAE;EACjE,MAAMC,SAAS,GAAGL,iBAAiB,CAACI,IAAI,CAAC;EACzC,MAAM,IAAIE,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KACpCP,QAAQ,CAACQ,OAAO,CAACN,QAAQ,CAACO,IAAY,CAAC,CAClCC,IAAI,CAACN,SAAS,CAAC,CACfO,EAAE,CAAC,OAAO,EAAEL,OAAO,CAAC,CACpBK,EAAE,CAAC,OAAO,EAAEJ,MAAM,CAC3B,CAAC;AACL"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { ChildProcess, ChildProcessByStdio, ChildProcessWithoutNullStreams, SpawnOptions, SpawnOptionsWithStdioTuple, SpawnOptionsWithoutStdio, StdioNull, StdioPipe } from "child_process";
|
|
4
|
-
import { Readable, Writable } from "stream";
|
|
5
|
-
export interface PromiseWithChildProcess<T> extends Promise<T> {
|
|
6
|
-
child: T;
|
|
7
|
-
}
|
|
8
|
-
export type Options = SpawnOptionsWithoutStdio | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe> | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull> | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe> | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe> | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull> | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull> | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe> | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull> | SpawnOptions;
|
|
9
|
-
/**
|
|
10
|
-
* @description get default options for spawnAsync
|
|
11
|
-
* @returns {Options} options
|
|
12
|
-
*/
|
|
13
|
-
export declare function getDefaultOptions(): Options;
|
|
14
|
-
/**
|
|
15
|
-
* @description set default options for spawnAsync
|
|
16
|
-
* @param {Options | ((prev: Options) => Options)} options
|
|
17
|
-
*/
|
|
18
|
-
export declare function setDefaultOptions(options: Options | ((prev: Options) => Options)): SpawnOptions | undefined;
|
|
19
|
-
export declare function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>;
|
|
20
|
-
export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>;
|
|
21
|
-
export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>;
|
|
22
|
-
export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>;
|
|
23
|
-
export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>;
|
|
24
|
-
export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>;
|
|
25
|
-
export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>;
|
|
26
|
-
export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>;
|
|
27
|
-
export declare function spawnAsync(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>;
|
|
28
|
-
export declare function spawnAsync(command: string, options: SpawnOptions): PromiseWithChildProcess<ChildProcess>;
|
|
29
|
-
export declare function spawnAsync(command: string, args?: readonly string[], options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>;
|
|
30
|
-
export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>;
|
|
31
|
-
export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>;
|
|
32
|
-
export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>;
|
|
33
|
-
export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>;
|
|
34
|
-
export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>;
|
|
35
|
-
export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>;
|
|
36
|
-
export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>;
|
|
37
|
-
export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>;
|
|
38
|
-
export declare function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): PromiseWithChildProcess<ChildProcess>;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { spawn } from "child_process";
|
|
2
|
-
let defaultOptions = {};
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @description get default options for spawnAsync
|
|
6
|
-
* @returns {Options} options
|
|
7
|
-
*/
|
|
8
|
-
export function getDefaultOptions() {
|
|
9
|
-
return defaultOptions;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @description set default options for spawnAsync
|
|
14
|
-
* @param {Options | ((prev: Options) => Options)} options
|
|
15
|
-
*/
|
|
16
|
-
export function setDefaultOptions(options) {
|
|
17
|
-
if (typeof options === "function") {
|
|
18
|
-
defaultOptions = options(defaultOptions);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
defaultOptions = options;
|
|
22
|
-
return defaultOptions;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @description wait for the command to exit
|
|
26
|
-
* @returns a promise that resolves with the child process when the command exits successfully. Also, the child process is attached to the promise as a property.
|
|
27
|
-
*/
|
|
28
|
-
export function spawnAsync(command, args, options) {
|
|
29
|
-
let child;
|
|
30
|
-
const promise = new Promise((resolve, reject) => {
|
|
31
|
-
if (Array.isArray(args)) options = {
|
|
32
|
-
...defaultOptions,
|
|
33
|
-
...options
|
|
34
|
-
};else args = {
|
|
35
|
-
...defaultOptions,
|
|
36
|
-
...args
|
|
37
|
-
};
|
|
38
|
-
child = spawn(command, args, options);
|
|
39
|
-
child.on("exit", code => {
|
|
40
|
-
if (code === 0) return resolve(child);
|
|
41
|
-
if (Array.isArray(args)) {
|
|
42
|
-
const args2 = args.map(item => item.trim()).filter(Boolean);
|
|
43
|
-
if (args2.length > 0) command = `${command} ${args2.join(" ")}`;
|
|
44
|
-
}
|
|
45
|
-
reject(new Error(`spawn "${command}" failed with code ${code}`));
|
|
46
|
-
return;
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
promise.child = child;
|
|
50
|
-
return promise;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=spawnAsync.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["spawn","defaultOptions","getDefaultOptions","setDefaultOptions","options","spawnAsync","command","args","child","promise","Promise","resolve","reject","Array","isArray","on","code","args2","map","item","trim","filter","Boolean","length","join","Error"],"sources":["../../../src/utils/spawnAsync.ts"],"sourcesContent":["import {\n ChildProcess,\n ChildProcessByStdio,\n ChildProcessWithoutNullStreams,\n SpawnOptions,\n SpawnOptionsWithStdioTuple,\n SpawnOptionsWithoutStdio,\n StdioNull,\n StdioPipe,\n spawn,\n} from \"child_process\"\nimport { Readable, Writable } from \"stream\"\n\nexport interface PromiseWithChildProcess<T> extends Promise<T> {\n child: T\n}\n\nexport type Options =\n | SpawnOptionsWithoutStdio\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n | SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n | SpawnOptions\n\nlet defaultOptions: Options = {}\n\n/**\n * @description get default options for spawnAsync\n * @returns {Options} options\n */\nexport function getDefaultOptions(): Options {\n return defaultOptions\n}\n\n/**\n * @description set default options for spawnAsync\n * @param {Options | ((prev: Options) => Options)} options\n */\nexport function setDefaultOptions(options: Options | ((prev: Options) => Options)) {\n if (typeof options === \"function\") {\n defaultOptions = options(defaultOptions)\n return\n }\n defaultOptions = options\n return defaultOptions\n}\n\nexport function spawnAsync(command: string, options?: SpawnOptionsWithoutStdio): PromiseWithChildProcess<ChildProcessWithoutNullStreams>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>\nexport function spawnAsync(\n command: string,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>\nexport function spawnAsync(command: string, options: SpawnOptions): PromiseWithChildProcess<ChildProcess>\nexport function spawnAsync(\n command: string,\n args?: readonly string[],\n options?: SpawnOptionsWithoutStdio,\n): PromiseWithChildProcess<ChildProcessWithoutNullStreams>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, Readable, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<Writable, null, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, Readable, null>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, Readable>>\nexport function spawnAsync(\n command: string,\n args: readonly string[],\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,\n): PromiseWithChildProcess<ChildProcessByStdio<null, null, null>>\nexport function spawnAsync(command: string, args: readonly string[], options: SpawnOptions): PromiseWithChildProcess<ChildProcess>\n\n/**\n * @description wait for the command to exit\n * @returns a promise that resolves with the child process when the command exits successfully. Also, the child process is attached to the promise as a property.\n */\nexport function spawnAsync(command: string, args?: any, options?: any): Promise<any> {\n let child: any\n const promise = new Promise<any>((resolve, reject) => {\n if (Array.isArray(args)) options = { ...defaultOptions, ...options }\n else args = { ...defaultOptions, ...args }\n child = spawn(command, args, options)\n child.on(\"exit\", (code: number) => {\n if (code === 0) return resolve(child)\n if (Array.isArray(args)) {\n const args2 = args.map((item: string) => item.trim()).filter(Boolean)\n if (args2.length > 0) command = `${command} ${args2.join(\" \")}`\n }\n reject(new Error(`spawn \"${command}\" failed with code ${code}`))\n return\n })\n }) as PromiseWithChildProcess<any>\n promise.child = child\n return promise\n}\n"],"mappings":"AAAA,SASIA,KAAK,QACF,eAAe;AAmBtB,IAAIC,cAAuB,GAAG,CAAC,CAAC;;AAEhC;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAA,EAAY;EACzC,OAAOD,cAAc;AACzB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASE,iBAAiBA,CAACC,OAA+C,EAAE;EAC/E,IAAI,OAAOA,OAAO,KAAK,UAAU,EAAE;IAC/BH,cAAc,GAAGG,OAAO,CAACH,cAAc,CAAC;IACxC;EACJ;EACAA,cAAc,GAAGG,OAAO;EACxB,OAAOH,cAAc;AACzB;AAmFA;AACA;AACA;AACA;AACA,OAAO,SAASI,UAAUA,CAACC,OAAe,EAAEC,IAAU,EAAEH,OAAa,EAAgB;EACjF,IAAII,KAAU;EACd,MAAMC,OAAO,GAAG,IAAIC,OAAO,CAAM,CAACC,OAAO,EAAEC,MAAM,KAAK;IAClD,IAAIC,KAAK,CAACC,OAAO,CAACP,IAAI,CAAC,EAAEH,OAAO,GAAG;MAAE,GAAGH,cAAc;MAAE,GAAGG;IAAQ,CAAC,MAC/DG,IAAI,GAAG;MAAE,GAAGN,cAAc;MAAE,GAAGM;IAAK,CAAC;IAC1CC,KAAK,GAAGR,KAAK,CAACM,OAAO,EAAEC,IAAI,EAAEH,OAAO,CAAC;IACrCI,KAAK,CAACO,EAAE,CAAC,MAAM,EAAGC,IAAY,IAAK;MAC/B,IAAIA,IAAI,KAAK,CAAC,EAAE,OAAOL,OAAO,CAACH,KAAK,CAAC;MACrC,IAAIK,KAAK,CAACC,OAAO,CAACP,IAAI,CAAC,EAAE;QACrB,MAAMU,KAAK,GAAGV,IAAI,CAACW,GAAG,CAAEC,IAAY,IAAKA,IAAI,CAACC,IAAI,CAAC,CAAC,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;QACrE,IAAIL,KAAK,CAACM,MAAM,GAAG,CAAC,EAAEjB,OAAO,GAAI,GAAEA,OAAQ,IAAGW,KAAK,CAACO,IAAI,CAAC,GAAG,CAAE,EAAC;MACnE;MACAZ,MAAM,CAAC,IAAIa,KAAK,CAAE,UAASnB,OAAQ,sBAAqBU,IAAK,EAAC,CAAC,CAAC;MAChE;IACJ,CAAC,CAAC;EACN,CAAC,CAAiC;EAClCP,OAAO,CAACD,KAAK,GAAGA,KAAK;EACrB,OAAOC,OAAO;AAClB"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type UnzipOptions = {
|
|
2
|
-
/**
|
|
3
|
-
* 要解压的文件
|
|
4
|
-
*/
|
|
5
|
-
input: string;
|
|
6
|
-
/**
|
|
7
|
-
* 解压到的目标文件夹位置
|
|
8
|
-
*/
|
|
9
|
-
output: string;
|
|
10
|
-
/**
|
|
11
|
-
* 压缩文件时的工作目录
|
|
12
|
-
*/
|
|
13
|
-
cwd?: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* 使用 7z 命令解压文件
|
|
17
|
-
* - 如果没有安装 7z,请先安装 7z 后再执行
|
|
18
|
-
* - 下载地址:https://www.7-zip.org/download.html
|
|
19
|
-
* - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中
|
|
20
|
-
* 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量
|
|
21
|
-
* 2. 在系统变量中找到并选中 Path,点击编辑
|
|
22
|
-
* 3. 点击新建,输入 7z 的安装路径(默认是 C:\Program Files\7-Zip),点击确定
|
|
23
|
-
* 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功
|
|
24
|
-
* 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确
|
|
25
|
-
*/
|
|
26
|
-
export declare function unzip({ input, output, cwd }: UnzipOptions): Promise<string>;
|
package/dist/esm/utils/unzip.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import which from "which";
|
|
2
|
-
import { execAsync } from "./execAsync";
|
|
3
|
-
/**
|
|
4
|
-
* 使用 7z 命令解压文件
|
|
5
|
-
* - 如果没有安装 7z,请先安装 7z 后再执行
|
|
6
|
-
* - 下载地址:https://www.7-zip.org/download.html
|
|
7
|
-
* - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中
|
|
8
|
-
* 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量
|
|
9
|
-
* 2. 在系统变量中找到并选中 Path,点击编辑
|
|
10
|
-
* 3. 点击新建,输入 7z 的安装路径(默认是 C:\Program Files\7-Zip),点击确定
|
|
11
|
-
* 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功
|
|
12
|
-
* 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确
|
|
13
|
-
*/
|
|
14
|
-
export async function unzip({
|
|
15
|
-
input,
|
|
16
|
-
output,
|
|
17
|
-
cwd
|
|
18
|
-
}) {
|
|
19
|
-
await which("7z");
|
|
20
|
-
return await execAsync(`7z x ${input} -o${output}`, {
|
|
21
|
-
cwd
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=unzip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["which","execAsync","unzip","input","output","cwd"],"sources":["../../../src/utils/unzip.ts"],"sourcesContent":["import which from \"which\"\n\nimport { execAsync } from \"./execAsync\"\n\nexport type UnzipOptions = {\n /**\n * 要解压的文件\n */\n input: string\n /**\n * 解压到的目标文件夹位置\n */\n output: string\n /**\n * 压缩文件时的工作目录\n */\n cwd?: string\n}\n\n/**\n * 使用 7z 命令解压文件\n * - 如果没有安装 7z,请先安装 7z 后再执行\n * - 下载地址:https://www.7-zip.org/download.html\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\n * 2. 在系统变量中找到并选中 Path,点击编辑\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\n */\nexport async function unzip({ input, output, cwd }: UnzipOptions) {\n await which(\"7z\")\n return await execAsync(`7z x ${input} -o${output}`, { cwd })\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,SAAS;AAiBlB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,KAAKA,CAAC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAkB,CAAC,EAAE;EAC9D,MAAML,KAAK,CAAC,IAAI,CAAC;EACjB,OAAO,MAAMC,SAAS,CAAE,QAAOE,KAAM,MAAKC,MAAO,EAAC,EAAE;IAAEC;EAAI,CAAC,CAAC;AAChE"}
|