@shipstatic/drop 2.13.0-beta.3 → 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 +2 -2
- package/dist/index.cjs +37 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -188,7 +188,7 @@ const ready = drop.files.filter(f => f.status === FileValidationStatus.READY);
|
|
|
188
188
|
|
|
189
189
|
## Build on upload
|
|
190
190
|
|
|
191
|
-
Drop recognises an unbuilt project (source files with `package.json` / `node_modules`) and sets `needsBuild`.
|
|
191
|
+
Drop recognises an unbuilt project (source files with `package.json` / `node_modules`) and sets `needsBuild`. `node_modules` stays behind (it is skipped during traversal and stripped from folder-picker selections), and so does whatever the project's `.gitignore` lists, read the way git reads it, so an old `dist/` the project ignores never rides along. A project's source isn't the site, so neither the entry-point check nor deploy validation applies to it: Astro, Next.js, SvelteKit and Eleventy have no `index.html` until they are built. Every file goes straight to `ready`, and the build gives the verdict.
|
|
192
192
|
|
|
193
193
|
Pass the signal through to the SDK:
|
|
194
194
|
|
|
@@ -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 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
|
@@ -282,6 +282,7 @@ function rebase(line, base) {
|
|
|
282
282
|
let body = negated ? pattern.slice(1) : pattern;
|
|
283
283
|
const directoryOnly = body.endsWith("/");
|
|
284
284
|
if (directoryOnly) body = body.slice(0, -1);
|
|
285
|
+
if (body.replace(/^\//, "") === "") return null;
|
|
285
286
|
const rebased = body.includes("/") ? `${folder}/${body.replace(/^\//, "")}` : `${folder}/**/${body}`;
|
|
286
287
|
return `${negated ? "!" : ""}${rebased}${directoryOnly ? "/" : ""}`;
|
|
287
288
|
}
|
|
@@ -292,6 +293,11 @@ async function projectSource(files) {
|
|
|
292
293
|
const matcher = ignore__default.default({ allowRelativePaths: true });
|
|
293
294
|
for (const { file, parts } of rules) {
|
|
294
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
|
+
}
|
|
295
301
|
const text = (await file.text()).replace(/^\uFEFF/, "");
|
|
296
302
|
for (const line of text.split(/\r?\n/)) {
|
|
297
303
|
const pattern = rebase(line, base);
|
|
@@ -1025,7 +1031,7 @@ async function processFiles(input, { limits, onStatus }) {
|
|
|
1025
1031
|
needsBuild: true,
|
|
1026
1032
|
status: {
|
|
1027
1033
|
title: "Ready",
|
|
1028
|
-
details: `${ship.pluralize(ready.length, "file", "files", true)} ready
|
|
1034
|
+
details: `${ship.pluralize(ready.length, "file", "files", true)} ready. We'll build the project.`
|
|
1029
1035
|
}
|
|
1030
1036
|
};
|
|
1031
1037
|
}
|
|
@@ -1090,24 +1096,38 @@ async function processFiles(input, { limits, onStatus }) {
|
|
|
1090
1096
|
}
|
|
1091
1097
|
|
|
1092
1098
|
// src/entries.ts
|
|
1093
|
-
|
|
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) {
|
|
1094
1103
|
try {
|
|
1095
|
-
|
|
1096
|
-
|
|
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) => {
|
|
1097
1115
|
entry.file(resolve, reject);
|
|
1098
|
-
})
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
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);
|
|
1111
1131
|
}
|
|
1112
1132
|
}
|
|
1113
1133
|
async function readDirectory(directory) {
|