@shipstatic/drop 2.12.1 → 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 +2 -2
- package/dist/index.cjs +48 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +44 -22
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -26,9 +26,9 @@ interface DropOutcome {
|
|
|
26
26
|
/**
|
|
27
27
|
* Run the pipeline.
|
|
28
28
|
*
|
|
29
|
-
* Never throws:
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Never throws: a missing entry point, a file over the limit, and an
|
|
30
|
+
* unexpected host-object failure all come back as an `error` outcome. Callers
|
|
31
|
+
* need no try/catch.
|
|
32
32
|
*/
|
|
33
33
|
declare function processFiles(input: File[], { limits, onStatus }: ProcessFilesOptions): Promise<DropOutcome>;
|
|
34
34
|
|
package/dist/index.d.ts
CHANGED
|
@@ -26,9 +26,9 @@ interface DropOutcome {
|
|
|
26
26
|
/**
|
|
27
27
|
* Run the pipeline.
|
|
28
28
|
*
|
|
29
|
-
* Never throws:
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Never throws: a missing entry point, a file over the limit, and an
|
|
30
|
+
* unexpected host-object failure all come back as an `error` outcome. Callers
|
|
31
|
+
* need no try/catch.
|
|
32
32
|
*/
|
|
33
33
|
declare function processFiles(input: File[], { limits, onStatus }: ProcessFilesOptions): Promise<DropOutcome>;
|
|
34
34
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { filterJunk, pluralize, validateFiles, optimizeDeployPaths } from '@shipstatic/ship';
|
|
2
|
+
import ignore from 'ignore';
|
|
2
3
|
import { useState, useRef, useMemo, useCallback } from 'react';
|
|
3
4
|
|
|
4
5
|
// src/process.ts
|
|
@@ -177,8 +178,8 @@ var UNBUILT_PROJECT_MARKERS = /* @__PURE__ */ new Set([
|
|
|
177
178
|
"package.json"
|
|
178
179
|
]);
|
|
179
180
|
function hasUnbuiltMarker(filePath2) {
|
|
180
|
-
const
|
|
181
|
-
return
|
|
181
|
+
const segments2 = filePath2.replace(/\\/g, "/").split("/").filter(Boolean);
|
|
182
|
+
return segments2.some((s) => UNBUILT_PROJECT_MARKERS.has(s));
|
|
182
183
|
}
|
|
183
184
|
var BILLING_RETURNS = {
|
|
184
185
|
checkout: ["upgrading", "true"],
|
|
@@ -266,6 +267,35 @@ function applyStatus(files, status, statusMessage) {
|
|
|
266
267
|
...statusMessage === void 0 ? {} : { statusMessage }
|
|
267
268
|
}));
|
|
268
269
|
}
|
|
270
|
+
function segments(file) {
|
|
271
|
+
return filePath(file).replace(/\\/g, "/").split("/").filter(Boolean);
|
|
272
|
+
}
|
|
273
|
+
function rebase(line, base) {
|
|
274
|
+
const pattern = line.replace(/(?<!\\) +$/, "");
|
|
275
|
+
if (pattern === "" || pattern.startsWith("#")) return null;
|
|
276
|
+
if (base === "") return pattern;
|
|
277
|
+
const negated = pattern.startsWith("!");
|
|
278
|
+
let body = negated ? pattern.slice(1) : pattern;
|
|
279
|
+
const directoryOnly = body.endsWith("/");
|
|
280
|
+
if (directoryOnly) body = body.slice(0, -1);
|
|
281
|
+
const rebased = body.includes("/") ? `${base}/${body.replace(/^\//, "")}` : `${base}/**/${body}`;
|
|
282
|
+
return `${negated ? "!" : ""}${rebased}${directoryOnly ? "/" : ""}`;
|
|
283
|
+
}
|
|
284
|
+
async function projectSource(files) {
|
|
285
|
+
const source = files.filter((file) => !segments(file).includes("node_modules"));
|
|
286
|
+
const rules = source.map((file) => ({ file, parts: segments(file) })).filter(({ parts }) => parts.at(-1) === ".gitignore").sort((a, b) => a.parts.length - b.parts.length);
|
|
287
|
+
if (rules.length === 0) return source;
|
|
288
|
+
const matcher = ignore({ allowRelativePaths: true });
|
|
289
|
+
for (const { file, parts } of rules) {
|
|
290
|
+
const base = parts.slice(0, -1).join("/");
|
|
291
|
+
const text = (await file.text()).replace(/^\uFEFF/, "");
|
|
292
|
+
for (const line of text.split(/\r?\n/)) {
|
|
293
|
+
const pattern = rebase(line, base);
|
|
294
|
+
if (pattern !== null) matcher.add(pattern);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return source.filter((file) => !matcher.ignores(segments(file).join("/")));
|
|
298
|
+
}
|
|
269
299
|
|
|
270
300
|
// node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js
|
|
271
301
|
var ch2 = {};
|
|
@@ -951,12 +981,12 @@ function detectSourceName(files) {
|
|
|
951
981
|
return path.includes("/") ? path.split("/")[0] : first.name;
|
|
952
982
|
}
|
|
953
983
|
function failure(params) {
|
|
954
|
-
const { title, details, errors, files = [], sourceName
|
|
984
|
+
const { title, details, errors, files = [], sourceName } = params;
|
|
955
985
|
return {
|
|
956
986
|
phase: "error",
|
|
957
987
|
files,
|
|
958
988
|
sourceName,
|
|
959
|
-
needsBuild,
|
|
989
|
+
needsBuild: false,
|
|
960
990
|
// `details` carries the single user-facing message; `errors` is for per-item
|
|
961
991
|
// breakdowns. Omitted when empty, otherwise consumers that render both
|
|
962
992
|
// fields show the message twice.
|
|
@@ -977,28 +1007,11 @@ async function processFiles(input, { limits, onStatus }) {
|
|
|
977
1007
|
files = input;
|
|
978
1008
|
}
|
|
979
1009
|
const needsBuild = files.some((f) => hasUnbuiltMarker(filePath(f)));
|
|
980
|
-
if (needsBuild)
|
|
981
|
-
files = files.filter(
|
|
982
|
-
(f) => !filePath(f).replace(/\\/g, "/").split("/").includes("node_modules")
|
|
983
|
-
);
|
|
984
|
-
}
|
|
1010
|
+
if (needsBuild) files = await projectSource(files);
|
|
985
1011
|
const kept = new Set(filterJunk(files.map(filePath), { allowUnbuilt: needsBuild }));
|
|
986
1012
|
const finalFiles = stripCommonPrefix(
|
|
987
1013
|
files.filter((f) => kept.has(filePath(f))).map((f) => createProcessedFile(f))
|
|
988
1014
|
);
|
|
989
|
-
if (finalFiles.length > 0) {
|
|
990
|
-
const hasIndex = needsBuild ? finalFiles.some((f) => f.path === "index.html" || f.path.endsWith("/index.html")) : finalFiles.some((f) => f.path === "index.html");
|
|
991
|
-
if (!hasIndex) {
|
|
992
|
-
const details = needsBuild ? "No index.html found \u2014 every web project needs an index.html entry point" : "No index.html at root \u2014 the entry point must be in the top-level directory";
|
|
993
|
-
return failure({
|
|
994
|
-
title: CANT_DEPLOY,
|
|
995
|
-
details,
|
|
996
|
-
sourceName,
|
|
997
|
-
needsBuild,
|
|
998
|
-
files: applyStatus(finalFiles, FileValidationStatus.VALIDATION_FAILED, details)
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
1015
|
if (needsBuild) {
|
|
1003
1016
|
const ready = applyStatus(finalFiles, FileValidationStatus.READY);
|
|
1004
1017
|
return {
|
|
@@ -1012,6 +1025,15 @@ async function processFiles(input, { limits, onStatus }) {
|
|
|
1012
1025
|
}
|
|
1013
1026
|
};
|
|
1014
1027
|
}
|
|
1028
|
+
if (finalFiles.length > 0 && !finalFiles.some((f) => f.path === "index.html")) {
|
|
1029
|
+
const details = "No index.html at root \u2014 the entry point must be in the top-level directory";
|
|
1030
|
+
return failure({
|
|
1031
|
+
title: CANT_DEPLOY,
|
|
1032
|
+
details,
|
|
1033
|
+
sourceName,
|
|
1034
|
+
files: applyStatus(finalFiles, FileValidationStatus.VALIDATION_FAILED, details)
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1015
1037
|
const validation = validateFiles(finalFiles.map(toValidatable), limits);
|
|
1016
1038
|
const validated = finalFiles.map((file, i) => ({
|
|
1017
1039
|
...file,
|