@shipstatic/drop 2.13.0-beta.4 → 2.13.0-beta.5

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 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
- - **Unreadable entries are skipped silently.** A folder with permission-denied files still deploys; the failures are logged to the console with no programmatic signal.
278
+ - **A folder read only in part is refused.** If any file or folder in a drop 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,38 @@ async function processFiles(input, { limits, onStatus }) {
1091
1096
  }
1092
1097
 
1093
1098
  // src/entries.ts
1094
- async function traverseFileTree(entry, files, currentPath = "") {
1099
+ function unreadable(path) {
1100
+ return `We couldn't read ${path}. Make sure it's on this computer, then try again.`;
1101
+ }
1102
+ async function readOrRefuse(path, read) {
1095
1103
  try {
1096
- if (entry.isFile) {
1097
- const file = await new Promise((resolve, reject) => {
1104
+ return await read();
1105
+ } catch {
1106
+ throw new Error(unreadable(path));
1107
+ }
1108
+ }
1109
+ async function traverseFileTree(entry, files, currentPath = "") {
1110
+ if (entry.isFile) {
1111
+ const path = currentPath ? `${currentPath}/${entry.name}` : entry.name;
1112
+ const file = await readOrRefuse(
1113
+ path,
1114
+ () => new Promise((resolve, reject) => {
1098
1115
  entry.file(resolve, reject);
1099
- });
1100
- setRelativePath(file, currentPath ? `${currentPath}/${file.name}` : file.name);
1101
- files.push(file);
1102
- return;
1103
- }
1104
- if (!entry.isDirectory) return;
1105
- for (const child of await readDirectory(entry)) {
1106
- if (child.isDirectory && child.name === "node_modules") continue;
1107
- const childPath = child.isDirectory ? currentPath ? `${currentPath}/${child.name}` : child.name : currentPath;
1108
- await traverseFileTree(child, files, childPath);
1109
- }
1110
- } catch (error) {
1111
- console.warn(`Error traversing file tree for entry ${entry.name}:`, error);
1116
+ })
1117
+ );
1118
+ setRelativePath(file, path);
1119
+ files.push(file);
1120
+ return;
1121
+ }
1122
+ if (!entry.isDirectory) return;
1123
+ const children = await readOrRefuse(
1124
+ currentPath || entry.name,
1125
+ () => readDirectory(entry)
1126
+ );
1127
+ for (const child of children) {
1128
+ if (child.isDirectory && child.name === "node_modules") continue;
1129
+ const childPath = child.isDirectory ? currentPath ? `${currentPath}/${child.name}` : child.name : currentPath;
1130
+ await traverseFileTree(child, files, childPath);
1112
1131
  }
1113
1132
  }
1114
1133
  async function readDirectory(directory) {