@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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { filterJunk, pluralize, validateFiles, optimizeDeployPaths } from '@shipstatic/ship';
1
+ import { pluralize, validateFiles, optimizeDeployPaths, sitePaths, unreadable } from '@shipstatic/ship';
2
2
  import ignore from 'ignore';
3
3
  import { useState, useRef, useMemo, useCallback } from 'react';
4
4
 
@@ -130,15 +130,21 @@ function createProcessedFile(file, options) {
130
130
  status: FileValidationStatus.PENDING
131
131
  };
132
132
  }
133
- function stripCommonPrefix(files) {
134
- if (files.length === 0) return files;
135
- const deployFiles = optimizeDeployPaths(files.map((f) => f.path));
136
- return files.map((f, i) => {
137
- const newPath = deployFiles[i].path;
138
- setRelativePath(f.file, newPath);
139
- return { ...f, path: newPath, name: newPath.split("/").pop() || f.name };
133
+ function published(file, path) {
134
+ setRelativePath(file.file, path);
135
+ return { ...file, path, name: path.split("/").pop() || file.name };
136
+ }
137
+ function siteFiles(files) {
138
+ const paths = sitePaths(files.map((f) => f.path));
139
+ return files.flatMap((file, i) => {
140
+ const path = paths[i];
141
+ return path == null ? [] : [published(file, path)];
140
142
  });
141
143
  }
144
+ function stripCommonPrefix(files) {
145
+ const paths = optimizeDeployPaths(files.map((f) => f.path));
146
+ return files.map((file, i) => published(file, paths[i].path));
147
+ }
142
148
  function applyStatus(files, status, statusMessage) {
143
149
  return files.map((f) => ({
144
150
  ...f,
@@ -894,12 +900,7 @@ async function processFiles(input, { limits, onStatus }) {
894
900
  files = input;
895
901
  }
896
902
  const needsBuild = files.some((f) => hasUnbuiltMarker(filePath(f)));
897
- if (needsBuild) files = await projectSource(files);
898
- if (!needsBuild) {
899
- const kept = new Set(filterJunk(files.map(filePath)));
900
- files = files.filter((f) => kept.has(filePath(f)));
901
- }
902
- const finalFiles = stripCommonPrefix(files.map((f) => createProcessedFile(f)));
903
+ const finalFiles = needsBuild ? stripCommonPrefix((await projectSource(files)).map((f) => createProcessedFile(f))) : siteFiles(files.map((f) => createProcessedFile(f)));
903
904
  if (needsBuild) {
904
905
  const ready = applyStatus(finalFiles, FileValidationStatus.READY);
905
906
  return {
@@ -950,12 +951,7 @@ async function processFiles(input, { limits, onStatus }) {
950
951
  });
951
952
  }
952
953
  }
953
-
954
- // src/entries.ts
955
954
  var UNREADABLE_DROP = "We couldn't read everything you dropped. Make sure the files are on this computer, then try again.";
956
- function unreadable(path) {
957
- return `We couldn't read ${path}. Make sure it's on this computer, then try again.`;
958
- }
959
955
  async function readOrRefuse(path, read) {
960
956
  try {
961
957
  return await read();