@shipstatic/drop 1.0.2 → 1.0.3
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 +35 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -61
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10070,6 +10070,26 @@ function useDrop(options) {
|
|
|
10070
10070
|
needsBuild: false
|
|
10071
10071
|
});
|
|
10072
10072
|
let detectedSourceName = "";
|
|
10073
|
+
const setErrorState = (params) => {
|
|
10074
|
+
const { title, details, errors, files = [], needsBuild = false } = params;
|
|
10075
|
+
setState({
|
|
10076
|
+
value: "error",
|
|
10077
|
+
files,
|
|
10078
|
+
sourceName: detectedSourceName,
|
|
10079
|
+
needsBuild,
|
|
10080
|
+
status: {
|
|
10081
|
+
title,
|
|
10082
|
+
details,
|
|
10083
|
+
...errors?.length && { errors }
|
|
10084
|
+
}
|
|
10085
|
+
});
|
|
10086
|
+
onValidationError?.({
|
|
10087
|
+
error: title,
|
|
10088
|
+
details,
|
|
10089
|
+
errors: errors ?? [],
|
|
10090
|
+
isClientError: true
|
|
10091
|
+
});
|
|
10092
|
+
};
|
|
10073
10093
|
try {
|
|
10074
10094
|
if (newFiles.length === 1 && isZipFile(newFiles[0])) {
|
|
10075
10095
|
detectedSourceName = newFiles[0].name.replace(/\.zip$/i, "");
|
|
@@ -10126,21 +10146,11 @@ function useDrop(options) {
|
|
|
10126
10146
|
status: FILE_STATUSES.VALIDATION_FAILED,
|
|
10127
10147
|
statusMessage: message
|
|
10128
10148
|
}));
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
files: filesWithStatus2,
|
|
10132
|
-
sourceName: detectedSourceName,
|
|
10133
|
-
needsBuild,
|
|
10134
|
-
status: {
|
|
10135
|
-
title: "Validation Failed",
|
|
10136
|
-
details: message
|
|
10137
|
-
}
|
|
10138
|
-
});
|
|
10139
|
-
onValidationError?.({
|
|
10140
|
-
error: "Validation Failed",
|
|
10149
|
+
setErrorState({
|
|
10150
|
+
title: "Validation Failed",
|
|
10141
10151
|
details: message,
|
|
10142
|
-
|
|
10143
|
-
|
|
10152
|
+
files: filesWithStatus2,
|
|
10153
|
+
needsBuild
|
|
10144
10154
|
});
|
|
10145
10155
|
return;
|
|
10146
10156
|
}
|
|
@@ -10170,25 +10180,11 @@ function useDrop(options) {
|
|
|
10170
10180
|
statusMessage: validation.files[idx]?.statusMessage || processedFile.statusMessage
|
|
10171
10181
|
}));
|
|
10172
10182
|
if (!validation.canDeploy) {
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
files: filesWithStatus,
|
|
10179
|
-
sourceName: detectedSourceName,
|
|
10180
|
-
needsBuild: false,
|
|
10181
|
-
status: {
|
|
10182
|
-
title: "Validation Failed",
|
|
10183
|
-
details: `${ship.pluralize(validation.errors.length, "file", "files", true)} failed validation`,
|
|
10184
|
-
errors: errorMessages
|
|
10185
|
-
}
|
|
10186
|
-
});
|
|
10187
|
-
onValidationError?.({
|
|
10188
|
-
error: "Validation Failed",
|
|
10189
|
-
details: ship.pluralize(validation.errors.length, "error", "errors", true),
|
|
10190
|
-
errors: errorMessages,
|
|
10191
|
-
isClientError: true
|
|
10183
|
+
setErrorState({
|
|
10184
|
+
title: "Validation Failed",
|
|
10185
|
+
details: `${ship.pluralize(validation.errors.length, "file", "files", true)} failed validation`,
|
|
10186
|
+
errors: validation.errors.map((err2) => `${err2.file}: ${err2.message}`),
|
|
10187
|
+
files: filesWithStatus
|
|
10192
10188
|
});
|
|
10193
10189
|
} else if (validation.validFiles.length > 0) {
|
|
10194
10190
|
let details = `${ship.pluralize(validation.validFiles.length, "file", "files", true)} ready`;
|
|
@@ -10224,42 +10220,20 @@ function useDrop(options) {
|
|
|
10224
10220
|
}
|
|
10225
10221
|
});
|
|
10226
10222
|
} else {
|
|
10227
|
-
|
|
10228
|
-
|
|
10223
|
+
setErrorState({
|
|
10224
|
+
title: "No Valid Files",
|
|
10229
10225
|
details: "None of the provided files could be processed.",
|
|
10230
|
-
|
|
10231
|
-
isClientError: true
|
|
10232
|
-
};
|
|
10233
|
-
setState({
|
|
10234
|
-
value: "error",
|
|
10235
|
-
files: filesWithStatus,
|
|
10236
|
-
sourceName: detectedSourceName,
|
|
10237
|
-
needsBuild: false,
|
|
10238
|
-
status: { title: noValidError.error, details: noValidError.details }
|
|
10226
|
+
files: filesWithStatus
|
|
10239
10227
|
});
|
|
10240
|
-
onValidationError?.(noValidError);
|
|
10241
10228
|
}
|
|
10242
10229
|
}
|
|
10243
10230
|
} catch (error) {
|
|
10244
10231
|
const message = error instanceof Error ? error.message : String(error);
|
|
10245
10232
|
const isValidation = isShipError(error);
|
|
10246
|
-
|
|
10247
|
-
|
|
10248
|
-
details: isValidation ? message : `Failed to process files: ${message}
|
|
10249
|
-
errors: [],
|
|
10250
|
-
isClientError: true
|
|
10251
|
-
};
|
|
10252
|
-
setState({
|
|
10253
|
-
value: "error",
|
|
10254
|
-
files: [],
|
|
10255
|
-
sourceName: detectedSourceName,
|
|
10256
|
-
needsBuild: false,
|
|
10257
|
-
status: {
|
|
10258
|
-
title: clientError.error,
|
|
10259
|
-
details: clientError.details
|
|
10260
|
-
}
|
|
10233
|
+
setErrorState({
|
|
10234
|
+
title: isValidation ? "Validation Failed" : "Processing Failed",
|
|
10235
|
+
details: isValidation ? message : `Failed to process files: ${message}`
|
|
10261
10236
|
});
|
|
10262
|
-
onValidationError?.(clientError);
|
|
10263
10237
|
} finally {
|
|
10264
10238
|
isProcessingRef.current = false;
|
|
10265
10239
|
}
|