@shipstatic/drop 2.16.1-beta.6 → 2.16.1-beta.8
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/dist/index.cjs +23 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -27
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -204,7 +204,7 @@ ShipStatic's own apps send a project to be built. That isn't part of the public
|
|
|
204
204
|
|
|
205
205
|
## ZIP handling
|
|
206
206
|
|
|
207
|
-
A **single** dropped ZIP is extracted and its contents deployed. ZIPs among several files are treated as ordinary files. Archive paths are sanitized against directory traversal (`../../config.json` → `config.json`).
|
|
207
|
+
A **single** dropped ZIP is extracted and its contents deployed. ZIPs among several files are treated as ordinary files. Archive paths are sanitized against directory traversal (`../../config.json` → `config.json`). A ZIP that can't be opened is an error that names it, and `extractZipToFiles()` rejects with the same sentence.
|
|
208
208
|
|
|
209
209
|
## Without React
|
|
210
210
|
|
package/dist/index.cjs
CHANGED
|
@@ -121,7 +121,7 @@ function setRelativePath(file, path) {
|
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
function filePath(file) {
|
|
124
|
-
return file.webkitRelativePath
|
|
124
|
+
return file.webkitRelativePath || file.name;
|
|
125
125
|
}
|
|
126
126
|
function createProcessedFile(file, options) {
|
|
127
127
|
const path = options?.path || filePath(file);
|
|
@@ -821,34 +821,30 @@ function unzip(data, opts, cb) {
|
|
|
821
821
|
|
|
822
822
|
// src/zip.ts
|
|
823
823
|
async function extractZipToFiles(zipFile) {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
files.push(file);
|
|
824
|
+
const bytes = new Uint8Array(await zipFile.arrayBuffer());
|
|
825
|
+
const entries = await new Promise((resolve, reject) => {
|
|
826
|
+
unzip(
|
|
827
|
+
bytes,
|
|
828
|
+
(err2, data) => err2 ? reject(
|
|
829
|
+
new Error(`We couldn't open ${zipFile.name}. It may be damaged, or not a ZIP file.`)
|
|
830
|
+
) : resolve(data)
|
|
831
|
+
);
|
|
832
|
+
});
|
|
833
|
+
const files = [];
|
|
834
|
+
const errors = [];
|
|
835
|
+
for (const [path, data] of Object.entries(entries)) {
|
|
836
|
+
if (path.endsWith("/") && data.length === 0) continue;
|
|
837
|
+
const sanitizedPath = normalizePath(path);
|
|
838
|
+
if (!sanitizedPath) {
|
|
839
|
+
errors.push(`Skipped invalid path: ${path}`);
|
|
840
|
+
continue;
|
|
842
841
|
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
errors: [
|
|
848
|
-
`Failed to load ZIP file: ${error instanceof Error ? error.message : String(error)}`
|
|
849
|
-
]
|
|
850
|
-
};
|
|
842
|
+
const filename = sanitizedPath.split("/").pop() || sanitizedPath;
|
|
843
|
+
const file = new File([new Uint8Array(data)], filename);
|
|
844
|
+
setRelativePath(file, sanitizedPath);
|
|
845
|
+
files.push(file);
|
|
851
846
|
}
|
|
847
|
+
return { files, errors };
|
|
852
848
|
}
|
|
853
849
|
function normalizePath(path) {
|
|
854
850
|
const normalized = [];
|