@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/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 = {};
|
|
@@ -977,11 +1007,7 @@ 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))
|