@shipstatic/drop 2.15.2-beta.1 → 2.16.0-beta.1

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/dist/index.cjs CHANGED
@@ -136,15 +136,21 @@ function createProcessedFile(file, options) {
136
136
  status: FileValidationStatus.PENDING
137
137
  };
138
138
  }
139
- function stripCommonPrefix(files) {
140
- if (files.length === 0) return files;
141
- const deployFiles = ship.optimizeDeployPaths(files.map((f) => f.path));
142
- return files.map((f, i) => {
143
- const newPath = deployFiles[i].path;
144
- setRelativePath(f.file, newPath);
145
- return { ...f, path: newPath, name: newPath.split("/").pop() || f.name };
139
+ function published(file, path) {
140
+ setRelativePath(file.file, path);
141
+ return { ...file, path, name: path.split("/").pop() || file.name };
142
+ }
143
+ function siteFiles(files) {
144
+ const paths = ship.sitePaths(files.map((f) => f.path));
145
+ return files.flatMap((file, i) => {
146
+ const path = paths[i];
147
+ return path == null ? [] : [published(file, path)];
146
148
  });
147
149
  }
150
+ function stripCommonPrefix(files) {
151
+ const paths = ship.optimizeDeployPaths(files.map((f) => f.path));
152
+ return files.map((file, i) => published(file, paths[i].path));
153
+ }
148
154
  function applyStatus(files, status, statusMessage) {
149
155
  return files.map((f) => ({
150
156
  ...f,
@@ -900,12 +906,7 @@ async function processFiles(input, { limits, onStatus }) {
900
906
  files = input;
901
907
  }
902
908
  const needsBuild = files.some((f) => hasUnbuiltMarker(filePath(f)));
903
- if (needsBuild) files = await projectSource(files);
904
- if (!needsBuild) {
905
- const kept = new Set(ship.filterJunk(files.map(filePath)));
906
- files = files.filter((f) => kept.has(filePath(f)));
907
- }
908
- const finalFiles = stripCommonPrefix(files.map((f) => createProcessedFile(f)));
909
+ const finalFiles = needsBuild ? stripCommonPrefix((await projectSource(files)).map((f) => createProcessedFile(f))) : siteFiles(files.map((f) => createProcessedFile(f)));
909
910
  if (needsBuild) {
910
911
  const ready = applyStatus(finalFiles, FileValidationStatus.READY);
911
912
  return {
@@ -956,17 +957,12 @@ async function processFiles(input, { limits, onStatus }) {
956
957
  });
957
958
  }
958
959
  }
959
-
960
- // src/entries.ts
961
960
  var UNREADABLE_DROP = "We couldn't read everything you dropped. Make sure the files are on this computer, then try again.";
962
- function unreadable(path) {
963
- return `We couldn't read ${path}. Make sure it's on this computer, then try again.`;
964
- }
965
961
  async function readOrRefuse(path, read) {
966
962
  try {
967
963
  return await read();
968
964
  } catch {
969
- throw new Error(unreadable(path));
965
+ throw new Error(ship.unreadable(path));
970
966
  }
971
967
  }
972
968
  async function traverseFileTree(entry, files, currentPath = "") {