@@ -21,23 +21,26 @@ export const getUploadJobStatus = async (job_id: string, appPath: string, pollAf
2121
2222export const updateProductInstallation = async ( appConfig : ZcliConfigFileContent , manifest : Manifest , app_id : string , product : string ) : Promise < boolean > => {
2323 const installationResp = await request . requestAPI ( `/api/${ product } /apps/installations.json` , { } , true )
24- const installations : Installations = installationResp . data
24+ const all_installations : Installations = installationResp . data
2525
2626 const configParams = appConfig ?. parameters || { } // if there are no parameters in the config, just attach an empty object
2727 const settings = manifest . parameters ? await getAppSettings ( manifest , configParams ) : { }
28- const installation_id = installations . installations . filter ( i => i . app_id === app_id ) [ 0 ] . id
28+ const installation = all_installations . installations . filter ( i => i . app_id === app_id )
29+ if ( installation . length > 0 ) {
30+ const installation_id = installation [ 0 ] . id
31+ const updated = await request . requestAPI ( `/api/${ product } /apps/installations/${ installation_id } .json` , {
32+ method : 'PUT' ,
33+ data : JSON . stringify ( { settings : { name : manifest . name , ...settings } } ) ,
34+ headers : {
35+ 'Content-Type' : 'application/json'
36+ }
37+ } )
2938
30- const updated = await request . requestAPI ( `/api/${ product } /apps/installations/${ installation_id } .json` , {
31- method : 'PUT' ,
32- data : JSON . stringify ( { settings : { name : manifest . name , ...settings } } ) ,
33- headers : {
34- 'Content-Type' : 'application/json'
39+ if ( updated . status === 201 || updated . status === 200 ) {
40+ return true
41+ } else {
42+ return false
3543 }
36- } )
37-
38- if ( updated . status === 201 || updated . status === 200 ) {
39- return true
40- } else {
41- return false
4244 }
45+ return true
4346}
0 commit comments