Bump the npm group with 4 updates (#2419)
* Bump the npm group with 4 updates Bumps the npm group with 4 updates: [adm-zip](https://github.com/cthackers/adm-zip), [@eslint/js](https://github.com/eslint/eslint/tree/HEAD/packages/js), [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) and [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser). Updates `adm-zip` from 0.5.14 to 0.5.15 - [Release notes](https://github.com/cthackers/adm-zip/releases) - [Changelog](https://github.com/cthackers/adm-zip/blob/master/history.md) - [Commits](https://github.com/cthackers/adm-zip/compare/v0.5.14...v0.5.15) Updates `@eslint/js` from 9.8.0 to 9.9.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/commits/v9.9.0/packages/js) Updates `@typescript-eslint/eslint-plugin` from 8.0.1 to 8.1.0 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.1.0/packages/eslint-plugin) Updates `@typescript-eslint/parser` from 8.0.1 to 8.1.0 - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.1.0/packages/parser) --- updated-dependencies: - dependency-name: adm-zip dependency-type: direct:production update-type: version-update:semver-patch dependency-group: npm - dependency-name: "@eslint/js" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm ... Signed-off-by: dependabot[bot] <support@github.com> * Update checked-in dependencies --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
25ad3c8e40
commit
d620faa0b4
103 changed files with 1631 additions and 740 deletions
162
node_modules/adm-zip/zipFile.js
generated
vendored
162
node_modules/adm-zip/zipFile.js
generated
vendored
|
|
@ -9,11 +9,12 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
mainHeader = new Headers.MainHeader(),
|
||||
loadedEntries = false;
|
||||
var password = null;
|
||||
const temporary = new Set();
|
||||
|
||||
// assign options
|
||||
const opts = Object.assign(Object.create(null), options);
|
||||
const opts = options;
|
||||
|
||||
const { noSort } = opts;
|
||||
const { noSort, decoder } = opts;
|
||||
|
||||
if (inBuffer) {
|
||||
// is a memory buffer
|
||||
|
|
@ -23,20 +24,31 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
loadedEntries = true;
|
||||
}
|
||||
|
||||
function iterateEntries(callback) {
|
||||
const totalEntries = mainHeader.diskEntries; // total number of entries
|
||||
let index = mainHeader.offset; // offset of first CEN header
|
||||
function makeTemporaryFolders() {
|
||||
const foldersList = new Set();
|
||||
|
||||
for (let i = 0; i < totalEntries; i++) {
|
||||
let tmp = index;
|
||||
const entry = new ZipEntry(inBuffer);
|
||||
// Make list of all folders in file
|
||||
for (const elem of Object.keys(entryTable)) {
|
||||
const elements = elem.split("/");
|
||||
elements.pop(); // filename
|
||||
if (!elements.length) continue; // no folders
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
const sub = elements.slice(0, i + 1).join("/") + "/";
|
||||
foldersList.add(sub);
|
||||
}
|
||||
}
|
||||
|
||||
entry.header = inBuffer.slice(tmp, (tmp += Utils.Constants.CENHDR));
|
||||
entry.entryName = inBuffer.slice(tmp, (tmp += entry.header.fileNameLength));
|
||||
|
||||
index += entry.header.centralHeaderSize;
|
||||
|
||||
callback(entry);
|
||||
// create missing folders as temporary
|
||||
for (const elem of foldersList) {
|
||||
if (!(elem in entryTable)) {
|
||||
const tempfolder = new ZipEntry(opts);
|
||||
tempfolder.entryName = elem;
|
||||
tempfolder.attr = 0x10;
|
||||
tempfolder.temporary = true;
|
||||
entryList.push(tempfolder);
|
||||
entryTable[tempfolder.entryName] = tempfolder;
|
||||
temporary.add(tempfolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -44,13 +56,13 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
loadedEntries = true;
|
||||
entryTable = {};
|
||||
if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
|
||||
throw new Error(Utils.Errors.DISK_ENTRY_TOO_LARGE);
|
||||
throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
|
||||
}
|
||||
entryList = new Array(mainHeader.diskEntries); // total number of entries
|
||||
var index = mainHeader.offset; // offset of first CEN header
|
||||
for (var i = 0; i < entryList.length; i++) {
|
||||
var tmp = index,
|
||||
entry = new ZipEntry(inBuffer);
|
||||
entry = new ZipEntry(opts, inBuffer);
|
||||
entry.header = inBuffer.slice(tmp, (tmp += Utils.Constants.CENHDR));
|
||||
|
||||
entry.entryName = inBuffer.slice(tmp, (tmp += entry.header.fileNameLength));
|
||||
|
|
@ -66,6 +78,8 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
entryList[i] = entry;
|
||||
entryTable[entry.entryName] = entry;
|
||||
}
|
||||
temporary.clear();
|
||||
makeTemporaryFolders();
|
||||
}
|
||||
|
||||
function readMainHeader(/*Boolean*/ readNow) {
|
||||
|
|
@ -76,6 +90,10 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
endOffset = -1, // Start offset of the END header
|
||||
commentEnd = 0;
|
||||
|
||||
// option to search header form entire file
|
||||
const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
|
||||
if (trailingSpace) max = 0;
|
||||
|
||||
for (i; i >= n; i--) {
|
||||
if (inBuffer[i] !== 0x50) continue; // quick check that the byte is 'P'
|
||||
if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
|
||||
|
|
@ -102,7 +120,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!~endOffset) throw new Error(Utils.Errors.INVALID_FORMAT);
|
||||
if (endOffset == -1) throw Utils.Errors.INVALID_FORMAT();
|
||||
|
||||
mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
|
||||
if (mainHeader.commentLength) {
|
||||
|
|
@ -126,7 +144,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
if (!loadedEntries) {
|
||||
readEntries();
|
||||
}
|
||||
return entryList;
|
||||
return entryList.filter((e) => !temporary.has(e));
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -134,10 +152,10 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
* @return {String}
|
||||
*/
|
||||
get comment() {
|
||||
return _comment.toString();
|
||||
return decoder.decode(_comment);
|
||||
},
|
||||
set comment(val) {
|
||||
_comment = Utils.toBuffer(val);
|
||||
_comment = Utils.toBuffer(val, decoder.encode);
|
||||
mainHeader.commentLength = _comment.length;
|
||||
},
|
||||
|
||||
|
|
@ -150,12 +168,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
},
|
||||
|
||||
forEach: function (callback) {
|
||||
if (!loadedEntries) {
|
||||
iterateEntries(callback);
|
||||
return;
|
||||
}
|
||||
|
||||
entryList.forEach(callback);
|
||||
this.entries.forEach(callback);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -186,27 +199,39 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
},
|
||||
|
||||
/**
|
||||
* Removes the entry with the given name from the entry list.
|
||||
* Removes the file with the given name from the entry list.
|
||||
*
|
||||
* If the entry is a directory, then all nested files and directories will be removed
|
||||
* @param entryName
|
||||
* @returns {void}
|
||||
*/
|
||||
deleteFile: function (/*String*/ entryName, withsubfolders = true) {
|
||||
if (!loadedEntries) {
|
||||
readEntries();
|
||||
}
|
||||
const entry = entryTable[entryName];
|
||||
const list = this.getEntryChildren(entry, withsubfolders).map((child) => child.entryName);
|
||||
|
||||
list.forEach(this.deleteEntry);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the entry with the given name from the entry list.
|
||||
*
|
||||
* @param {string} entryName
|
||||
* @returns {void}
|
||||
*/
|
||||
deleteEntry: function (/*String*/ entryName) {
|
||||
if (!loadedEntries) {
|
||||
readEntries();
|
||||
}
|
||||
var entry = entryTable[entryName];
|
||||
if (entry && entry.isDirectory) {
|
||||
var _self = this;
|
||||
this.getEntryChildren(entry).forEach(function (child) {
|
||||
if (child.entryName !== entryName) {
|
||||
_self.deleteEntry(child.entryName);
|
||||
}
|
||||
});
|
||||
const entry = entryTable[entryName];
|
||||
const index = entryList.indexOf(entry);
|
||||
if (index >= 0) {
|
||||
entryList.splice(index, 1);
|
||||
delete entryTable[entryName];
|
||||
mainHeader.totalEntries = entryList.length;
|
||||
}
|
||||
entryList.splice(entryList.indexOf(entry), 1);
|
||||
delete entryTable[entryName];
|
||||
mainHeader.totalEntries = entryList.length;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -215,25 +240,42 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
* @param entry
|
||||
* @return Array
|
||||
*/
|
||||
getEntryChildren: function (/*ZipEntry*/ entry) {
|
||||
getEntryChildren: function (/*ZipEntry*/ entry, subfolders = true) {
|
||||
if (!loadedEntries) {
|
||||
readEntries();
|
||||
}
|
||||
if (entry && entry.isDirectory) {
|
||||
const list = [];
|
||||
const name = entry.entryName;
|
||||
const len = name.length;
|
||||
if (typeof entry === "object") {
|
||||
if (entry.isDirectory && subfolders) {
|
||||
const list = [];
|
||||
const name = entry.entryName;
|
||||
|
||||
entryList.forEach(function (zipEntry) {
|
||||
if (zipEntry.entryName.substr(0, len) === name) {
|
||||
list.push(zipEntry);
|
||||
for (const zipEntry of entryList) {
|
||||
if (zipEntry.entryName.startsWith(name)) {
|
||||
list.push(zipEntry);
|
||||
}
|
||||
}
|
||||
});
|
||||
return list;
|
||||
return list;
|
||||
} else {
|
||||
return [entry];
|
||||
}
|
||||
}
|
||||
return [];
|
||||
},
|
||||
|
||||
/**
|
||||
* How many child elements entry has
|
||||
*
|
||||
* @param {ZipEntry} entry
|
||||
* @return {integer}
|
||||
*/
|
||||
getChildCount: function (entry) {
|
||||
if (entry && entry.isDirectory) {
|
||||
const list = this.getEntryChildren(entry);
|
||||
return list.includes(entry) ? list.length - 1 : list.length;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the zip file
|
||||
*
|
||||
|
|
@ -252,8 +294,9 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
|
||||
mainHeader.size = 0;
|
||||
mainHeader.offset = 0;
|
||||
totalEntries = 0;
|
||||
|
||||
for (const entry of entryList) {
|
||||
for (const entry of this.entries) {
|
||||
// compress data and set local and entry header accordingly. Reason why is called first
|
||||
const compressedData = entry.getCompressedData();
|
||||
entry.header.offset = dindex;
|
||||
|
|
@ -275,11 +318,13 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
// 5. update main header
|
||||
mainHeader.size += centralHeader.length;
|
||||
totalSize += dataLength + centralHeader.length;
|
||||
totalEntries++;
|
||||
}
|
||||
|
||||
totalSize += mainHeader.mainHeaderSize; // also includes zip file comment length
|
||||
// point to end of data and beginning of central directory first record
|
||||
mainHeader.offset = dindex;
|
||||
mainHeader.totalEntries = totalEntries;
|
||||
|
||||
dindex = 0;
|
||||
const outBuffer = Buffer.alloc(totalSize);
|
||||
|
|
@ -302,6 +347,13 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
}
|
||||
mh.copy(outBuffer, dindex);
|
||||
|
||||
// Since we update entry and main header offsets,
|
||||
// they are no longer valid and we have to reset content
|
||||
// (Issue 64)
|
||||
|
||||
inBuffer = outBuffer;
|
||||
loadedEntries = false;
|
||||
|
||||
return outBuffer;
|
||||
},
|
||||
|
||||
|
|
@ -316,6 +368,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
const centralHeaders = [];
|
||||
let totalSize = 0;
|
||||
let dindex = 0;
|
||||
let totalEntries = 0;
|
||||
|
||||
mainHeader.size = 0;
|
||||
mainHeader.offset = 0;
|
||||
|
|
@ -345,6 +398,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
centralHeaders.push(centalHeader);
|
||||
mainHeader.size += centalHeader.length;
|
||||
totalSize += dataLength + centalHeader.length;
|
||||
totalEntries++;
|
||||
|
||||
compress2Buffer(entryLists);
|
||||
});
|
||||
|
|
@ -352,6 +406,7 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
totalSize += mainHeader.mainHeaderSize; // also includes zip file comment length
|
||||
// point to end of data and beginning of central directory first record
|
||||
mainHeader.offset = dindex;
|
||||
mainHeader.totalEntries = totalEntries;
|
||||
|
||||
dindex = 0;
|
||||
const outBuffer = Buffer.alloc(totalSize);
|
||||
|
|
@ -371,11 +426,18 @@ module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
|
|||
|
||||
mh.copy(outBuffer, dindex); // write main header
|
||||
|
||||
// Since we update entry and main header offsets, they are no
|
||||
// longer valid and we have to reset content using our new buffer
|
||||
// (Issue 64)
|
||||
|
||||
inBuffer = outBuffer;
|
||||
loadedEntries = false;
|
||||
|
||||
onSuccess(outBuffer);
|
||||
}
|
||||
};
|
||||
|
||||
compress2Buffer(Array.from(entryList));
|
||||
compress2Buffer(Array.from(this.entries));
|
||||
} catch (e) {
|
||||
onFail(e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue