@shipstatic/drop 2.13.0-beta.4 → 2.13.0-beta.6
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 +53 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -275,7 +275,7 @@ vi.mock('@shipstatic/drop', () => ({ useDrop: mockUseDrop({ phase: 'ready' }) })
|
|
|
275
275
|
|
|
276
276
|
- **`webkitRelativePath` is the handoff.** Drop writes each file's deploy path there, and the ShipStatic SDK reads it. Don't modify it in between.
|
|
277
277
|
- **`stripCommonPrefix` mutates File objects.** It returns new `ProcessedFile`s but rewrites `webkitRelativePath` on the underlying `File` — deliberately, because that's what the SDK reads.
|
|
278
|
-
- **
|
|
278
|
+
- **A drop read only in part is refused.** If any file, folder or dropped item cannot be read, the drop ends in the `error` phase under "Couldn't prepare the files", naming what could not be read. Nothing is deployed without it.
|
|
279
279
|
- **No MD5 here.** Ship computes each file's MD5 for its manifest.
|
|
280
280
|
- **`type` is the browser's report.** The platform derives `Content-Type` server-side from the path, so drop bundles no MIME database.
|
|
281
281
|
|
package/dist/index.cjs
CHANGED
|
@@ -293,6 +293,11 @@ async function projectSource(files) {
|
|
|
293
293
|
const matcher = ignore__default.default({ allowRelativePaths: true });
|
|
294
294
|
for (const { file, parts } of rules) {
|
|
295
295
|
const base = parts.slice(0, -1).join("/");
|
|
296
|
+
if (/[\r\n]/.test(base)) {
|
|
297
|
+
throw new Error(
|
|
298
|
+
"A folder in this project has a line break in its name, so its .gitignore can't be read. Rename the folder, then try again."
|
|
299
|
+
);
|
|
300
|
+
}
|
|
296
301
|
const text = (await file.text()).replace(/^\uFEFF/, "");
|
|
297
302
|
for (const line of text.split(/\r?\n/)) {
|
|
298
303
|
const pattern = rebase(line, base);
|
|
@@ -1091,24 +1096,39 @@ async function processFiles(input, { limits, onStatus }) {
|
|
|
1091
1096
|
}
|
|
1092
1097
|
|
|
1093
1098
|
// src/entries.ts
|
|
1094
|
-
|
|
1099
|
+
var UNREADABLE_DROP = "We couldn't read everything you dropped. Make sure the files are on this computer, then try again.";
|
|
1100
|
+
function unreadable(path) {
|
|
1101
|
+
return `We couldn't read ${path}. Make sure it's on this computer, then try again.`;
|
|
1102
|
+
}
|
|
1103
|
+
async function readOrRefuse(path, read) {
|
|
1095
1104
|
try {
|
|
1096
|
-
|
|
1097
|
-
|
|
1105
|
+
return await read();
|
|
1106
|
+
} catch {
|
|
1107
|
+
throw new Error(unreadable(path));
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
async function traverseFileTree(entry, files, currentPath = "") {
|
|
1111
|
+
if (entry.isFile) {
|
|
1112
|
+
const path = currentPath ? `${currentPath}/${entry.name}` : entry.name;
|
|
1113
|
+
const file = await readOrRefuse(
|
|
1114
|
+
path,
|
|
1115
|
+
() => new Promise((resolve, reject) => {
|
|
1098
1116
|
entry.file(resolve, reject);
|
|
1099
|
-
})
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1117
|
+
})
|
|
1118
|
+
);
|
|
1119
|
+
setRelativePath(file, path);
|
|
1120
|
+
files.push(file);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
if (!entry.isDirectory) return;
|
|
1124
|
+
const children = await readOrRefuse(
|
|
1125
|
+
currentPath || entry.name,
|
|
1126
|
+
() => readDirectory(entry)
|
|
1127
|
+
);
|
|
1128
|
+
for (const child of children) {
|
|
1129
|
+
if (child.isDirectory && child.name === "node_modules") continue;
|
|
1130
|
+
const childPath = child.isDirectory ? currentPath ? `${currentPath}/${child.name}` : child.name : currentPath;
|
|
1131
|
+
await traverseFileTree(child, files, childPath);
|
|
1112
1132
|
}
|
|
1113
1133
|
}
|
|
1114
1134
|
async function readDirectory(directory) {
|
|
@@ -1229,27 +1249,29 @@ function useDrop({ ship }) {
|
|
|
1229
1249
|
setState((prev) => prev.isDragging ? { ...prev, isDragging: false } : prev);
|
|
1230
1250
|
const files = [];
|
|
1231
1251
|
const directories = [];
|
|
1252
|
+
let unreadable2 = false;
|
|
1232
1253
|
for (const item of Array.from(e.dataTransfer.items)) {
|
|
1233
1254
|
if (item.kind !== "file") continue;
|
|
1255
|
+
let entry;
|
|
1234
1256
|
try {
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
if (file) files.push(file);
|
|
1257
|
+
entry = item.webkitGetAsEntry?.();
|
|
1258
|
+
} catch {
|
|
1259
|
+
}
|
|
1260
|
+
if (entry?.isDirectory) {
|
|
1261
|
+
directories.push({ entry, path: entry.name });
|
|
1262
|
+
continue;
|
|
1263
|
+
}
|
|
1264
|
+
const file = item.getAsFile();
|
|
1265
|
+
if (file) {
|
|
1266
|
+
setRelativePath(file, file.name);
|
|
1267
|
+
files.push(file);
|
|
1268
|
+
} else {
|
|
1269
|
+
unreadable2 = true;
|
|
1249
1270
|
}
|
|
1250
1271
|
}
|
|
1251
|
-
if (directories.length === 0 && files.length === 0) return;
|
|
1272
|
+
if (directories.length === 0 && files.length === 0 && !unreadable2) return;
|
|
1252
1273
|
await prepare(async () => {
|
|
1274
|
+
if (unreadable2) throw new Error(UNREADABLE_DROP);
|
|
1253
1275
|
await Promise.all(directories.map((d) => traverseFileTree(d.entry, files, d.path)));
|
|
1254
1276
|
return files;
|
|
1255
1277
|
});
|