@agent-nexus/csreg 0.1.4 → 0.1.5
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 +20 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -784,14 +784,28 @@ async function pushSingle(resolved) {
|
|
|
784
784
|
spin.succeed("Version prepared.");
|
|
785
785
|
spin.start("Uploading archive...");
|
|
786
786
|
const archiveData = readFileSync3(archive.path);
|
|
787
|
-
const
|
|
787
|
+
const uploadHeaders = {
|
|
788
|
+
"Content-Type": "application/gzip",
|
|
789
|
+
"Content-Length": String(archive.size)
|
|
790
|
+
};
|
|
791
|
+
let uploadResponse = await fetch(prepared.uploadUrl, {
|
|
788
792
|
method: "PUT",
|
|
789
|
-
headers:
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
},
|
|
793
|
-
body: archiveData
|
|
793
|
+
headers: uploadHeaders,
|
|
794
|
+
body: archiveData,
|
|
795
|
+
redirect: "manual"
|
|
794
796
|
});
|
|
797
|
+
if (uploadResponse.status === 301 || uploadResponse.status === 302 || uploadResponse.status === 307 || uploadResponse.status === 308) {
|
|
798
|
+
const redirectUrl = uploadResponse.headers.get("location");
|
|
799
|
+
if (!redirectUrl) {
|
|
800
|
+
spin.fail("Upload failed.");
|
|
801
|
+
throw new CliError("Upload redirect missing Location header.");
|
|
802
|
+
}
|
|
803
|
+
uploadResponse = await fetch(redirectUrl, {
|
|
804
|
+
method: "PUT",
|
|
805
|
+
headers: uploadHeaders,
|
|
806
|
+
body: archiveData
|
|
807
|
+
});
|
|
808
|
+
}
|
|
795
809
|
if (!uploadResponse.ok) {
|
|
796
810
|
spin.fail("Upload failed.");
|
|
797
811
|
throw new CliError(`Upload failed with status ${uploadResponse.status}.`, [
|