@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/dist/index.js
CHANGED
|
@@ -287,6 +287,11 @@ async function projectSource(files) {
|
|
|
287
287
|
const matcher = ignore({ allowRelativePaths: true });
|
|
288
288
|
for (const { file, parts } of rules) {
|
|
289
289
|
const base = parts.slice(0, -1).join("/");
|
|
290
|
+
if (/[\r\n]/.test(base)) {
|
|
291
|
+
throw new Error(
|
|
292
|
+
"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."
|
|
293
|
+
);
|
|
294
|
+
}
|
|
290
295
|
const text = (await file.text()).replace(/^\uFEFF/, "");
|
|
291
296
|
for (const line of text.split(/\r?\n/)) {
|
|
292
297
|
const pattern = rebase(line, base);
|
|
@@ -1085,24 +1090,39 @@ async function processFiles(input, { limits, onStatus }) {
|
|
|
1085
1090
|
}
|
|
1086
1091
|
|
|
1087
1092
|
// src/entries.ts
|
|
1088
|
-
|
|
1093
|
+
var UNREADABLE_DROP = "We couldn't read everything you dropped. Make sure the files are on this computer, then try again.";
|
|
1094
|
+
function unreadable(path) {
|
|
1095
|
+
return `We couldn't read ${path}. Make sure it's on this computer, then try again.`;
|
|
1096
|
+
}
|
|
1097
|
+
async function readOrRefuse(path, read) {
|
|
1089
1098
|
try {
|
|
1090
|
-
|
|
1091
|
-
|
|
1099
|
+
return await read();
|
|
1100
|
+
} catch {
|
|
1101
|
+
throw new Error(unreadable(path));
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
async function traverseFileTree(entry, files, currentPath = "") {
|
|
1105
|
+
if (entry.isFile) {
|
|
1106
|
+
const path = currentPath ? `${currentPath}/${entry.name}` : entry.name;
|
|
1107
|
+
const file = await readOrRefuse(
|
|
1108
|
+
path,
|
|
1109
|
+
() => new Promise((resolve, reject) => {
|
|
1092
1110
|
entry.file(resolve, reject);
|
|
1093
|
-
})
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1111
|
+
})
|
|
1112
|
+
);
|
|
1113
|
+
setRelativePath(file, path);
|
|
1114
|
+
files.push(file);
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
if (!entry.isDirectory) return;
|
|
1118
|
+
const children = await readOrRefuse(
|
|
1119
|
+
currentPath || entry.name,
|
|
1120
|
+
() => readDirectory(entry)
|
|
1121
|
+
);
|
|
1122
|
+
for (const child of children) {
|
|
1123
|
+
if (child.isDirectory && child.name === "node_modules") continue;
|
|
1124
|
+
const childPath = child.isDirectory ? currentPath ? `${currentPath}/${child.name}` : child.name : currentPath;
|
|
1125
|
+
await traverseFileTree(child, files, childPath);
|
|
1106
1126
|
}
|
|
1107
1127
|
}
|
|
1108
1128
|
async function readDirectory(directory) {
|
|
@@ -1223,27 +1243,29 @@ function useDrop({ ship }) {
|
|
|
1223
1243
|
setState((prev) => prev.isDragging ? { ...prev, isDragging: false } : prev);
|
|
1224
1244
|
const files = [];
|
|
1225
1245
|
const directories = [];
|
|
1246
|
+
let unreadable2 = false;
|
|
1226
1247
|
for (const item of Array.from(e.dataTransfer.items)) {
|
|
1227
1248
|
if (item.kind !== "file") continue;
|
|
1249
|
+
let entry;
|
|
1228
1250
|
try {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
if (file) files.push(file);
|
|
1251
|
+
entry = item.webkitGetAsEntry?.();
|
|
1252
|
+
} catch {
|
|
1253
|
+
}
|
|
1254
|
+
if (entry?.isDirectory) {
|
|
1255
|
+
directories.push({ entry, path: entry.name });
|
|
1256
|
+
continue;
|
|
1257
|
+
}
|
|
1258
|
+
const file = item.getAsFile();
|
|
1259
|
+
if (file) {
|
|
1260
|
+
setRelativePath(file, file.name);
|
|
1261
|
+
files.push(file);
|
|
1262
|
+
} else {
|
|
1263
|
+
unreadable2 = true;
|
|
1243
1264
|
}
|
|
1244
1265
|
}
|
|
1245
|
-
if (directories.length === 0 && files.length === 0) return;
|
|
1266
|
+
if (directories.length === 0 && files.length === 0 && !unreadable2) return;
|
|
1246
1267
|
await prepare(async () => {
|
|
1268
|
+
if (unreadable2) throw new Error(UNREADABLE_DROP);
|
|
1247
1269
|
await Promise.all(directories.map((d) => traverseFileTree(d.entry, files, d.path)));
|
|
1248
1270
|
return files;
|
|
1249
1271
|
});
|