archiver-node 8.0.0 → 8.0.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/README.md +1 -1
- package/cjs/Archiver.js +755 -0
- package/cjs/archivers/JsonArchive.js +44 -0
- package/cjs/archivers/TarArchive.js +44 -0
- package/cjs/archivers/ZipArchive.js +44 -0
- package/cjs/error.js +62 -0
- package/cjs/lazystream.js +66 -0
- package/cjs/package.json +5 -0
- package/cjs/plugins/json.js +110 -0
- package/cjs/plugins/tar.js +147 -0
- package/cjs/plugins/zip.js +103 -0
- package/cjs/utils.js +92 -0
- package/index.cjs +4 -0
- package/index.d.ts +138 -0
- package/index.js +4 -39
- package/lib/{core.js → Archiver.js} +1 -1
- package/lib/archivers/JsonArchive.js +13 -0
- package/lib/archivers/TarArchive.js +13 -0
- package/lib/archivers/ZipArchive.js +13 -0
- package/lib/lazystream.js +91 -0
- package/package.json +20 -5
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
var JsonArchive_exports = {};
|
|
29
|
+
__export(JsonArchive_exports, {
|
|
30
|
+
default: () => JsonArchive
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(JsonArchive_exports);
|
|
33
|
+
var import_Archiver = __toESM(require("../Archiver.js"), 1);
|
|
34
|
+
var import_json = __toESM(require("../plugins/json.js"), 1);
|
|
35
|
+
class JsonArchive extends import_Archiver.default {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
super(options);
|
|
38
|
+
this._format = "json";
|
|
39
|
+
this._module = new import_json.default(options);
|
|
40
|
+
this._supportsDirectory = true;
|
|
41
|
+
this._supportsSymlink = true;
|
|
42
|
+
this._modulePipe();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
var TarArchive_exports = {};
|
|
29
|
+
__export(TarArchive_exports, {
|
|
30
|
+
default: () => TarArchive
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(TarArchive_exports);
|
|
33
|
+
var import_Archiver = __toESM(require("../Archiver.js"), 1);
|
|
34
|
+
var import_tar = __toESM(require("../plugins/tar.js"), 1);
|
|
35
|
+
class TarArchive extends import_Archiver.default {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
super(options);
|
|
38
|
+
this._format = "tar";
|
|
39
|
+
this._module = new import_tar.default(options);
|
|
40
|
+
this._supportsDirectory = true;
|
|
41
|
+
this._supportsSymlink = true;
|
|
42
|
+
this._modulePipe();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
var ZipArchive_exports = {};
|
|
29
|
+
__export(ZipArchive_exports, {
|
|
30
|
+
default: () => ZipArchive
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(ZipArchive_exports);
|
|
33
|
+
var import_Archiver = __toESM(require("../Archiver.js"), 1);
|
|
34
|
+
var import_zip = __toESM(require("../plugins/zip.js"), 1);
|
|
35
|
+
class ZipArchive extends import_Archiver.default {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
super(options);
|
|
38
|
+
this._format = "zip";
|
|
39
|
+
this._module = new import_zip.default(options);
|
|
40
|
+
this._supportsDirectory = true;
|
|
41
|
+
this._supportsSymlink = true;
|
|
42
|
+
this._modulePipe();
|
|
43
|
+
}
|
|
44
|
+
}
|
package/cjs/error.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
var error_exports = {};
|
|
29
|
+
__export(error_exports, {
|
|
30
|
+
ArchiverError: () => ArchiverError
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(error_exports);
|
|
33
|
+
var import_util = __toESM(require("util"), 1);
|
|
34
|
+
const ERROR_CODES = {
|
|
35
|
+
ABORTED: "archive was aborted",
|
|
36
|
+
DIRECTORYDIRPATHREQUIRED: "diretory dirpath argument must be a non-empty string value",
|
|
37
|
+
DIRECTORYFUNCTIONINVALIDDATA: "invalid data returned by directory custom data function",
|
|
38
|
+
ENTRYNAMEREQUIRED: "entry name must be a non-empty string value",
|
|
39
|
+
FILEFILEPATHREQUIRED: "file filepath argument must be a non-empty string value",
|
|
40
|
+
FINALIZING: "archive already finalizing",
|
|
41
|
+
QUEUECLOSED: "queue closed",
|
|
42
|
+
NOENDMETHOD: "no suitable finalize/end method defined by module",
|
|
43
|
+
DIRECTORYNOTSUPPORTED: "support for directory entries not defined by module",
|
|
44
|
+
FORMATSET: "archive format already set",
|
|
45
|
+
INPUTSTEAMBUFFERREQUIRED: "input source must be valid Stream or Buffer instance",
|
|
46
|
+
MODULESET: "module already set",
|
|
47
|
+
SYMLINKNOTSUPPORTED: "support for symlink entries not defined by module",
|
|
48
|
+
SYMLINKFILEPATHREQUIRED: "symlink filepath argument must be a non-empty string value",
|
|
49
|
+
SYMLINKTARGETREQUIRED: "symlink target argument must be a non-empty string value",
|
|
50
|
+
ENTRYNOTSUPPORTED: "entry not supported"
|
|
51
|
+
};
|
|
52
|
+
function ArchiverError(code, data) {
|
|
53
|
+
Error.captureStackTrace(this, this.constructor);
|
|
54
|
+
this.message = ERROR_CODES[code] || code;
|
|
55
|
+
this.code = code;
|
|
56
|
+
this.data = data;
|
|
57
|
+
}
|
|
58
|
+
import_util.default.inherits(ArchiverError, Error);
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
ArchiverError
|
|
62
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
var lazystream_exports = {};
|
|
19
|
+
__export(lazystream_exports, {
|
|
20
|
+
Readable: () => Readable,
|
|
21
|
+
Writable: () => Writable
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(lazystream_exports);
|
|
24
|
+
var import_stream = require("stream");
|
|
25
|
+
function beforeFirstCall(instance, method, callback) {
|
|
26
|
+
instance[method] = function(...args) {
|
|
27
|
+
delete instance[method];
|
|
28
|
+
callback.apply(this, args);
|
|
29
|
+
return this[method].apply(this, args);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
class Readable extends import_stream.PassThrough {
|
|
33
|
+
constructor(fn, options) {
|
|
34
|
+
super(options);
|
|
35
|
+
if (!(this instanceof Readable)) {
|
|
36
|
+
return new Readable(fn, options);
|
|
37
|
+
}
|
|
38
|
+
beforeFirstCall(this, "_read", function() {
|
|
39
|
+
const source = fn.call(this, options);
|
|
40
|
+
const emit = this.emit.bind(this, "error");
|
|
41
|
+
source.on("error", emit);
|
|
42
|
+
source.pipe(this);
|
|
43
|
+
});
|
|
44
|
+
this.emit("readable");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
class Writable extends import_stream.PassThrough {
|
|
48
|
+
constructor(fn, options) {
|
|
49
|
+
super(options);
|
|
50
|
+
if (!(this instanceof Writable)) {
|
|
51
|
+
return new Writable(fn, options);
|
|
52
|
+
}
|
|
53
|
+
beforeFirstCall(this, "_write", function() {
|
|
54
|
+
const destination = fn.call(this, options);
|
|
55
|
+
const emit = this.emit.bind(this, "error");
|
|
56
|
+
destination.on("error", emit);
|
|
57
|
+
this.pipe(destination);
|
|
58
|
+
});
|
|
59
|
+
this.emit("writable");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
Readable,
|
|
65
|
+
Writable
|
|
66
|
+
});
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
var json_exports = {};
|
|
29
|
+
__export(json_exports, {
|
|
30
|
+
default: () => Json
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(json_exports);
|
|
33
|
+
var import_readable_stream = require("readable-stream");
|
|
34
|
+
var import_buffer_crc32 = __toESM(require("buffer-crc32"), 1);
|
|
35
|
+
var import_utils = require("../utils.js");
|
|
36
|
+
/**
|
|
37
|
+
* JSON Format Plugin
|
|
38
|
+
*
|
|
39
|
+
* @module plugins/json
|
|
40
|
+
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
|
|
41
|
+
* @copyright (c) 2012-2014 Chris Talkington, contributors.
|
|
42
|
+
*/
|
|
43
|
+
class Json extends import_readable_stream.Transform {
|
|
44
|
+
/**
|
|
45
|
+
* @constructor
|
|
46
|
+
* @param {(JsonOptions|TransformOptions)} options
|
|
47
|
+
*/
|
|
48
|
+
constructor(options) {
|
|
49
|
+
super({ ...options });
|
|
50
|
+
this.files = [];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* [_transform description]
|
|
54
|
+
*
|
|
55
|
+
* @private
|
|
56
|
+
* @param {Buffer} chunk
|
|
57
|
+
* @param {String} encoding
|
|
58
|
+
* @param {Function} callback
|
|
59
|
+
* @return void
|
|
60
|
+
*/
|
|
61
|
+
_transform(chunk, encoding, callback) {
|
|
62
|
+
callback(null, chunk);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* [_writeStringified description]
|
|
66
|
+
*
|
|
67
|
+
* @private
|
|
68
|
+
* @return void
|
|
69
|
+
*/
|
|
70
|
+
_writeStringified() {
|
|
71
|
+
var fileString = JSON.stringify(this.files);
|
|
72
|
+
this.write(fileString);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* [append description]
|
|
76
|
+
*
|
|
77
|
+
* @param {(Buffer|Stream)} source
|
|
78
|
+
* @param {EntryData} data
|
|
79
|
+
* @param {Function} callback
|
|
80
|
+
* @return void
|
|
81
|
+
*/
|
|
82
|
+
append(source, data, callback) {
|
|
83
|
+
var self = this;
|
|
84
|
+
data.crc32 = 0;
|
|
85
|
+
function onend(err, sourceBuffer) {
|
|
86
|
+
if (err) {
|
|
87
|
+
callback(err);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
data.size = sourceBuffer.length || 0;
|
|
91
|
+
data.crc32 = import_buffer_crc32.default.unsigned(sourceBuffer);
|
|
92
|
+
self.files.push(data);
|
|
93
|
+
callback(null, data);
|
|
94
|
+
}
|
|
95
|
+
if (data.sourceType === "buffer") {
|
|
96
|
+
onend(null, source);
|
|
97
|
+
} else if (data.sourceType === "stream") {
|
|
98
|
+
(0, import_utils.collectStream)(source, onend);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* [finalize description]
|
|
103
|
+
*
|
|
104
|
+
* @return void
|
|
105
|
+
*/
|
|
106
|
+
finalize() {
|
|
107
|
+
this._writeStringified();
|
|
108
|
+
this.end();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
var tar_exports = {};
|
|
29
|
+
__export(tar_exports, {
|
|
30
|
+
default: () => Tar
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(tar_exports);
|
|
33
|
+
var import_zlib = __toESM(require("zlib"), 1);
|
|
34
|
+
var import_tar_stream = __toESM(require("tar-stream"), 1);
|
|
35
|
+
var import_utils = require("../utils.js");
|
|
36
|
+
/**
|
|
37
|
+
* TAR Format Plugin
|
|
38
|
+
*
|
|
39
|
+
* @module plugins/tar
|
|
40
|
+
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
|
|
41
|
+
* @copyright (c) 2012-2014 Chris Talkington, contributors.
|
|
42
|
+
*/
|
|
43
|
+
class Tar {
|
|
44
|
+
/**
|
|
45
|
+
* @constructor
|
|
46
|
+
* @param {TarOptions} options
|
|
47
|
+
*/
|
|
48
|
+
constructor(options) {
|
|
49
|
+
options = this.options = {
|
|
50
|
+
gzip: false,
|
|
51
|
+
...options
|
|
52
|
+
};
|
|
53
|
+
if (typeof options.gzipOptions !== "object") {
|
|
54
|
+
options.gzipOptions = {};
|
|
55
|
+
}
|
|
56
|
+
this.engine = import_tar_stream.default.pack(options);
|
|
57
|
+
this.compressor = false;
|
|
58
|
+
if (options.gzip) {
|
|
59
|
+
this.compressor = import_zlib.default.createGzip(options.gzipOptions);
|
|
60
|
+
this.compressor.on("error", this._onCompressorError.bind(this));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* [_onCompressorError description]
|
|
65
|
+
*
|
|
66
|
+
* @private
|
|
67
|
+
* @param {Error} err
|
|
68
|
+
* @return void
|
|
69
|
+
*/
|
|
70
|
+
_onCompressorError(err) {
|
|
71
|
+
this.engine.emit("error", err);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* [append description]
|
|
75
|
+
*
|
|
76
|
+
* @param {(Buffer|Stream)} source
|
|
77
|
+
* @param {TarEntryData} data
|
|
78
|
+
* @param {Function} callback
|
|
79
|
+
* @return void
|
|
80
|
+
*/
|
|
81
|
+
append(source, data, callback) {
|
|
82
|
+
var self = this;
|
|
83
|
+
data.mtime = data.date;
|
|
84
|
+
function append(err, sourceBuffer) {
|
|
85
|
+
if (err) {
|
|
86
|
+
callback(err);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
self.engine.entry(data, sourceBuffer, function(err2) {
|
|
90
|
+
callback(err2, data);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (data.sourceType === "buffer") {
|
|
94
|
+
append(null, source);
|
|
95
|
+
} else if (data.sourceType === "stream" && data.stats) {
|
|
96
|
+
data.size = data.stats.size;
|
|
97
|
+
var entry = self.engine.entry(data, function(err) {
|
|
98
|
+
callback(err, data);
|
|
99
|
+
});
|
|
100
|
+
source.pipe(entry);
|
|
101
|
+
} else if (data.sourceType === "stream") {
|
|
102
|
+
(0, import_utils.collectStream)(source, append);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* [finalize description]
|
|
107
|
+
*
|
|
108
|
+
* @return void
|
|
109
|
+
*/
|
|
110
|
+
finalize() {
|
|
111
|
+
this.engine.finalize();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* [on description]
|
|
115
|
+
*
|
|
116
|
+
* @return this.engine
|
|
117
|
+
*/
|
|
118
|
+
on() {
|
|
119
|
+
return this.engine.on.apply(this.engine, arguments);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* [pipe description]
|
|
123
|
+
*
|
|
124
|
+
* @param {String} destination
|
|
125
|
+
* @param {Object} options
|
|
126
|
+
* @return this.engine
|
|
127
|
+
*/
|
|
128
|
+
pipe(destination, options) {
|
|
129
|
+
if (this.compressor) {
|
|
130
|
+
return this.engine.pipe.apply(this.engine, [this.compressor]).pipe(destination, options);
|
|
131
|
+
} else {
|
|
132
|
+
return this.engine.pipe.apply(this.engine, arguments);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* [unpipe description]
|
|
137
|
+
*
|
|
138
|
+
* @return this.engine
|
|
139
|
+
*/
|
|
140
|
+
unpipe() {
|
|
141
|
+
if (this.compressor) {
|
|
142
|
+
return this.compressor.unpipe.apply(this.compressor, arguments);
|
|
143
|
+
} else {
|
|
144
|
+
return this.engine.unpipe.apply(this.engine, arguments);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
var zip_exports = {};
|
|
29
|
+
__export(zip_exports, {
|
|
30
|
+
default: () => Zip
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(zip_exports);
|
|
33
|
+
var import_zip_stream = __toESM(require("zip-stream"), 1);
|
|
34
|
+
/**
|
|
35
|
+
* ZIP Format Plugin
|
|
36
|
+
*
|
|
37
|
+
* @module plugins/zip
|
|
38
|
+
* @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
|
|
39
|
+
* @copyright (c) 2012-2014 Chris Talkington, contributors.
|
|
40
|
+
*/
|
|
41
|
+
class Zip {
|
|
42
|
+
/**
|
|
43
|
+
* @constructor
|
|
44
|
+
* @param {ZipOptions} [options]
|
|
45
|
+
* @param {String} [options.comment] Sets the zip archive comment.
|
|
46
|
+
* @param {Boolean} [options.forceLocalTime=false] Forces the archive to contain local file times instead of UTC.
|
|
47
|
+
* @param {Boolean} [options.forceZip64=false] Forces the archive to contain ZIP64 headers.
|
|
48
|
+
* @param {Boolean} [options.namePrependSlash=false] Prepends a forward slash to archive file paths.
|
|
49
|
+
* @param {Boolean} [options.store=false] Sets the compression method to STORE.
|
|
50
|
+
* @param {Object} [options.zlib] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
|
|
51
|
+
*/
|
|
52
|
+
constructor(options) {
|
|
53
|
+
options = this.options = {
|
|
54
|
+
comment: "",
|
|
55
|
+
forceUTC: false,
|
|
56
|
+
namePrependSlash: false,
|
|
57
|
+
store: false,
|
|
58
|
+
...options
|
|
59
|
+
};
|
|
60
|
+
this.engine = new import_zip_stream.default(options);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @param {(Buffer|Stream)} source
|
|
64
|
+
* @param {ZipEntryData} data
|
|
65
|
+
* @param {String} data.name Sets the entry name including internal path.
|
|
66
|
+
* @param {(String|Date)} [data.date=NOW()] Sets the entry date.
|
|
67
|
+
* @param {Number} [data.mode=D:0755/F:0644] Sets the entry permissions.
|
|
68
|
+
* @param {String} [data.prefix] Sets a path prefix for the entry name. Useful
|
|
69
|
+
* when working with methods like `directory` or `glob`.
|
|
70
|
+
* @param {fs.Stats} [data.stats] Sets the fs stat data for this entry allowing
|
|
71
|
+
* for reduction of fs stat calls when stat data is already known.
|
|
72
|
+
* @param {Boolean} [data.store=ZipOptions.store] Sets the compression method to STORE.
|
|
73
|
+
* @param {Function} callback
|
|
74
|
+
* @return void
|
|
75
|
+
*/
|
|
76
|
+
append(source, data, callback) {
|
|
77
|
+
this.engine.entry(source, data, callback);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @return void
|
|
81
|
+
*/
|
|
82
|
+
finalize() {
|
|
83
|
+
this.engine.finalize();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @return this.engine
|
|
87
|
+
*/
|
|
88
|
+
on() {
|
|
89
|
+
return this.engine.on.apply(this.engine, arguments);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @return this.engine
|
|
93
|
+
*/
|
|
94
|
+
pipe() {
|
|
95
|
+
return this.engine.pipe.apply(this.engine, arguments);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @return this.engine
|
|
99
|
+
*/
|
|
100
|
+
unpipe() {
|
|
101
|
+
return this.engine.unpipe.apply(this.engine, arguments);
|
|
102
|
+
}
|
|
103
|
+
}
|