@shipstatic/drop 2.12.2-beta.0 → 2.13.0-beta.0
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 +37 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
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`. `node_modules` is skipped during traversal and stripped from folder-picker selections. 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.
|
|
191
|
+
Drop recognises an unbuilt project (source files with `package.json` / `node_modules`) and sets `needsBuild`. The project is sent as its repository holds it: `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/` 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
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var ship = require('@shipstatic/ship');
|
|
4
|
+
var ignore = require('ignore');
|
|
4
5
|
var react = require('react');
|
|
5
6
|
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var ignore__default = /*#__PURE__*/_interopDefault(ignore);
|
|
10
|
+
|
|
6
11
|
// src/process.ts
|
|
7
12
|
var ErrorType = {
|
|
8
13
|
/**
|
|
@@ -179,8 +184,8 @@ var UNBUILT_PROJECT_MARKERS = /* @__PURE__ */ new Set([
|
|
|
179
184
|
"package.json"
|
|
180
185
|
]);
|
|
181
186
|
function hasUnbuiltMarker(filePath2) {
|
|
182
|
-
const
|
|
183
|
-
return
|
|
187
|
+
const segments2 = filePath2.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
188
|
+
return segments2.some((s) => UNBUILT_PROJECT_MARKERS.has(s));
|
|
184
189
|
}
|
|
185
190
|
var BILLING_RETURNS = {
|
|
186
191
|
checkout: ["upgrading", "true"],
|
|
@@ -268,6 +273,35 @@ function applyStatus(files, status, statusMessage) {
|
|
|
268
273
|
...statusMessage === void 0 ? {} : { statusMessage }
|
|
269
274
|
}));
|
|
270
275
|
}
|
|
276
|
+
function segments(file) {
|
|
277
|
+
return filePath(file).replace(/\\/g, "/").split("/").filter(Boolean);
|
|
278
|
+
}
|
|
279
|
+
function rebase(line, base) {
|
|
280
|
+
const pattern = line.replace(/(?<!\\) +$/, "");
|
|
281
|
+
if (pattern === "" || pattern.startsWith("#")) return null;
|
|
282
|
+
if (base === "") return pattern;
|
|
283
|
+
const negated = pattern.startsWith("!");
|
|
284
|
+
let body = negated ? pattern.slice(1) : pattern;
|
|
285
|
+
const directoryOnly = body.endsWith("/");
|
|
286
|
+
if (directoryOnly) body = body.slice(0, -1);
|
|
287
|
+
const rebased = body.includes("/") ? `${base}/${body.replace(/^\//, "")}` : `${base}/**/${body}`;
|
|
288
|
+
return `${negated ? "!" : ""}${rebased}${directoryOnly ? "/" : ""}`;
|
|
289
|
+
}
|
|
290
|
+
async function projectSource(files) {
|
|
291
|
+
const source = files.filter((file) => !segments(file).includes("node_modules"));
|
|
292
|
+
const rules = source.map((file) => ({ file, parts: segments(file) })).filter(({ parts }) => parts.at(-1) === ".gitignore").sort((a, b) => a.parts.length - b.parts.length);
|
|
293
|
+
if (rules.length === 0) return source;
|
|
294
|
+
const matcher = ignore__default.default({ allowRelativePaths: true });
|
|
295
|
+
for (const { file, parts } of rules) {
|
|
296
|
+
const base = parts.slice(0, -1).join("/");
|
|
297
|
+
const text = (await file.text()).replace(/^\uFEFF/, "");
|
|
298
|
+
for (const line of text.split(/\r?\n/)) {
|
|
299
|
+
const pattern = rebase(line, base);
|
|
300
|
+
if (pattern !== null) matcher.add(pattern);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return source.filter((file) => !matcher.ignores(segments(file).join("/")));
|
|
304
|
+
}
|
|
271
305
|
|
|
272
306
|
// node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js
|
|
273
307
|
var ch2 = {};
|
|
@@ -979,11 +1013,7 @@ async function processFiles(input, { limits, onStatus }) {
|
|
|
979
1013
|
files = input;
|
|
980
1014
|
}
|
|
981
1015
|
const needsBuild = files.some((f) => hasUnbuiltMarker(filePath(f)));
|
|
982
|
-
if (needsBuild)
|
|
983
|
-
files = files.filter(
|
|
984
|
-
(f) => !filePath(f).replace(/\\/g, "/").split("/").includes("node_modules")
|
|
985
|
-
);
|
|
986
|
-
}
|
|
1016
|
+
if (needsBuild) files = await projectSource(files);
|
|
987
1017
|
const kept = new Set(ship.filterJunk(files.map(filePath), { allowUnbuilt: needsBuild }));
|
|
988
1018
|
const finalFiles = stripCommonPrefix(
|
|
989
1019
|
files.filter((f) => kept.has(filePath(f))).map((f) => createProcessedFile(f))
|