diff --git a/cloudron.js b/cloudron.js index 94dd766..a619f47 100644 --- a/cloudron.js +++ b/cloudron.js @@ -230,9 +230,19 @@ Cloudron.prototype.uninstallApp = function (appId) { assert(false, 'uninstallApp failed'); }; -Cloudron.prototype.updateApp = function (appId, newManifest) { +Cloudron.prototype.updateApp = function (appId, manifestOrAppstoreId) { process.stdout.write('Trying to update'); - var res = request.post(this._origin + '/api/v1/apps/' + appId + '/update').query({ access_token: this._credentials.accessToken }).send({ password: this._credentials.password, manifest: newManifest }).end(); + + var data = { + password: this._credentials.password, + manifest: typeof manifestOrAppstoreId === 'object' ? manifestOrAppstoreId : null, + appStoreId: typeof manifestOrAppstoreId === 'string' ? manifestOrAppstoreId : null + }; + + var res = request.post(this._origin + '/api/v1/apps/' + appId + '/update') + .query({ access_token: this._credentials.accessToken }) + .send(data) + .end(); common.verifyResponse2xx(res, 'Could not update'); console.log('Update started'.green); diff --git a/test/app-update-test.js b/test/app-update-test.js index 0eac63f..de9d027 100644 --- a/test/app-update-test.js +++ b/test/app-update-test.js @@ -6,10 +6,8 @@ 'use strict'; var AppStore = require('../appstore.js'), - assert = require('assert'), Cloudron = require('../cloudron.js'), - common = require('../common.js'), - request = require('superagent-sync'); + common = require('../common.js'); require('colors'); @@ -57,13 +55,11 @@ describe('Application update test', function () { var location = 'test' + (Math.random() * 10000).toFixed(); it('can install app', function () { - var manifest = appStore.getManifest(APP_ID, APP_OLD_VERSION); - appId = cloudron.installApp(location, manifest); + appId = cloudron.installApp(location, APP_ID + '@' + APP_OLD_VERSION); }); it('update the app', function () { - var manifest = appStore.getManifest(APP_ID, APP_NEW_VERSION); - cloudron.updateApp(appId, manifest); + cloudron.updateApp(appId, APP_ID + '@' + APP_NEW_VERSION); }); it('can uninstall app', function () {