Comparing version 0.5.0 to 0.7.0
const got = require('got') | ||
const fs = require('fs') | ||
const FormData = require('form-data') | ||
const EventEmitter = require('events').EventEmitter | ||
const baseUrl = 'https://api.fandogh.cloud/fa/api/' | ||
@@ -97,3 +99,2 @@ const { buildImageZip, getConfigValue } = require('../helpers') | ||
try { | ||
let imageName = getConfigValue({source, type:'name'}) | ||
imageName = name || imageName | ||
@@ -114,3 +115,6 @@ let headers = client.tokenHeader(token) | ||
*/ | ||
postVersion: async ({name, version, source, token}) => { | ||
postVersion: async ({name, version, source, token}) => { | ||
const emitter = new EventEmitter(); | ||
try { | ||
@@ -121,7 +125,15 @@ let imageName = getConfigValue({source, type:'name'}) | ||
let compressedSource = await buildImageZip(source) | ||
let formData = { | ||
source: fs.createReadStream(compressedSource), | ||
version | ||
} | ||
return await client.request({api: `images/${imageName}/versions`, method:'POST', headers, formData}) | ||
const form = new FormData(); | ||
form.append('source', fs.createReadStream(compressedSource)); | ||
form.append('version', version) | ||
got.post(`images/${imageName}/versions`, {baseUrl, headers, body: form}).on('uploadProgress', progress => { | ||
emitter.emit('uploadProgress', progress) | ||
if(progress.percent === 1){ | ||
emitter.emit('finish', progress) | ||
} | ||
}).catch(e => { | ||
emitter.emit('error', e) | ||
Promise.reject(e) | ||
}) | ||
return emitter; | ||
} catch(e) { | ||
@@ -146,3 +158,3 @@ return Promise.reject(e) | ||
/** | ||
* | ||
* depracated | ||
* @param image_name | ||
@@ -168,3 +180,3 @@ * @param image_version | ||
postService: async ({token, manifest}) => { | ||
postManifest: async ({token, manifest}) => { | ||
try { | ||
@@ -171,0 +183,0 @@ let headers = client.tokenHeader(token) |
@@ -66,7 +66,4 @@ const {getToken, getImages, postImage, getVersions, postVersion, getServices, postService, getLogs, postManifest} = require('./client') | ||
createVersion: async ({name, version, source, token}) => { | ||
try { | ||
return await postVersion({token,version, source, name}) | ||
} catch(e) { | ||
return Promise.reject(e) | ||
} | ||
return await postVersion({token,version, source, name}) | ||
}, | ||
@@ -99,3 +96,3 @@ /** | ||
try { | ||
return await postService({token, params: {image_name, image_version, service_name, environment_variables, port, service_type, source}}) | ||
return postService({token, params: {image_name, image_version, service_name, environment_variables, port, service_type, source}}) | ||
} catch(e) { | ||
@@ -126,3 +123,3 @@ return Promise.reject(e) | ||
try { | ||
return await postManifest({token, service_name}) | ||
return await postManifest({token, manifest}) | ||
} catch(e) { | ||
@@ -129,0 +126,0 @@ return Promise.reject(e) |
{ | ||
"name": "fandogh", | ||
"version": "0.5.0", | ||
"version": "0.7.0", | ||
"description": "fandogh node client", | ||
@@ -13,2 +13,3 @@ "main": "fandogh.js", | ||
"archiver": "^2.1.1", | ||
"form-data": "^2.3.3", | ||
"got": "^9.3.2", | ||
@@ -15,0 +16,0 @@ "js-yaml": "^3.12.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12481
442
5
6
+ Addedform-data@^2.3.3
+ Addedasynckit@0.4.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@2.5.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedsafe-buffer@5.2.1(transitive)