1- import { createReadStream } from "fs" ;
1+ import { createReadStream , readFileSync } from "fs" ;
22import pathlib from "path" ;
33import fs from "fs-extra" ;
44import { isPlainObject , template } from "lodash-es" ;
@@ -80,10 +80,6 @@ export default async (pluginConfig, context) => {
8080 debug ( "file target: %o" , target ) ;
8181 debug ( "file status: %o" , status ) ;
8282
83- // Uploaded assets to the project
84- const form = new FormData ( ) ;
85- form . append ( "file" , createReadStream ( file ) ) ;
86-
8783 let uploadEndpoint ;
8884 let response ;
8985
@@ -100,15 +96,15 @@ export default async (pluginConfig, context) => {
10096 debug ( "PUT-ing the file %s to %s" , file , uploadEndpoint ) ;
10197
10298 try {
103- response = await got . put ( uploadEndpoint , { ...apiOptions , body : form } ) . json ( ) ;
99+ response = await got . put ( uploadEndpoint , { ...apiOptions , ... proxy , body : readFileSync ( file ) } ) . json ( ) ;
104100 } catch ( error ) {
105101 logger . error ( "An error occurred while uploading %s to the GitLab generics package API:\n%O" , file , error ) ;
106102 throw error ;
107103 }
108104
109105 const { url } = response . file ;
110106
111- assetsList . push ( { label, alt : "release" , url, type : "package" , filepath } ) ;
107+ assetsList . push ( { label, alt : "release" , url, type : "package" , filepath, target } ) ;
112108
113109 logger . log ( "Uploaded file: %s" , url ) ;
114110 } else {
@@ -118,6 +114,8 @@ export default async (pluginConfig, context) => {
118114 debug ( "POST-ing the file %s to %s" , file , uploadEndpoint ) ;
119115
120116 try {
117+ const form = new FormData ( ) ;
118+ form . append ( "file" , createReadStream ( file ) ) ;
121119 response = await got . post ( uploadEndpoint , { ...apiOptions , ...proxy , body : form } ) . json ( ) ;
122120 } catch ( error ) {
123121 logger . error ( "An error occurred while uploading %s to the GitLab project uploads API:\n%O" , file , error ) ;
@@ -126,7 +124,7 @@ export default async (pluginConfig, context) => {
126124
127125 const { url, alt } = response ;
128126
129- assetsList . push ( { label, alt, url, type, filepath } ) ;
127+ assetsList . push ( { label, alt, url, type, filepath, target } ) ;
130128
131129 logger . log ( "Uploaded file: %s" , url ) ;
132130 }
@@ -145,10 +143,10 @@ export default async (pluginConfig, context) => {
145143 description : notes && notes . trim ( ) ? notes : gitTag ,
146144 milestones,
147145 assets : {
148- links : assetsList . map ( ( { label, alt, url, type, filepath, rawUrl } ) => {
146+ links : assetsList . map ( ( { label, alt, url, type, filepath, rawUrl, target } ) => {
149147 return {
150148 name : label || alt ,
151- url : rawUrl || urlJoin ( gitlabUrl , repoId , url ) ,
149+ url : rawUrl || ( target === "generic_package" ? url : urlJoin ( gitlabUrl , repoId , url ) ) ,
152150 link_type : type ,
153151 filepath,
154152 } ;
0 commit comments