Move ecosystem loading to common.js
This commit is contained in:
parent
df80a776b1
commit
6b06bca675
13
appstore.js
13
appstore.js
@ -1,8 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var debug = require('debug')('e2e:appstore'),
|
var common = require('./common.js'),
|
||||||
fs = require('fs'),
|
debug = require('debug')('e2e:appstore'),
|
||||||
path = require('path'),
|
|
||||||
request = require('superagent-sync'),
|
request = require('superagent-sync'),
|
||||||
sleep = require('sleep').sleep,
|
sleep = require('sleep').sleep,
|
||||||
stripe = require('stripe');
|
stripe = require('stripe');
|
||||||
@ -17,12 +16,6 @@ function AppStore(origin) {
|
|||||||
password: null,
|
password: null,
|
||||||
accessToken: null
|
accessToken: null
|
||||||
};
|
};
|
||||||
|
|
||||||
if (fs.existsSync(path.join(__dirname, '../ecosystem.json'))) {
|
|
||||||
this._ecosystem = require(path.join(__dirname, '../ecosystem.json')); // staging appstore
|
|
||||||
} else {
|
|
||||||
this._ecosystem = require(path.join(__dirname, '../keys/appstore/ecosystem-staging.json'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function verifyResponse(res, errorMessage) {
|
function verifyResponse(res, errorMessage) {
|
||||||
@ -106,7 +99,7 @@ AppStore.prototype.restore = function (boxId, backupId) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
AppStore.prototype.setupBilling = function (callback) {
|
AppStore.prototype.setupBilling = function (callback) {
|
||||||
var stripeApi = stripe(this._ecosystem.env['STRIPE_SECRET']);
|
var stripeApi = stripe(common.stripeSecret());
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
|
15
common.js
15
common.js
@ -9,9 +9,15 @@ exports = module.exports = {
|
|||||||
cloudronDomain: cloudronDomain,
|
cloudronDomain: cloudronDomain,
|
||||||
verifyResponse: verifyResponse,
|
verifyResponse: verifyResponse,
|
||||||
getOwner: getOwner,
|
getOwner: getOwner,
|
||||||
|
stripeSecret: stripeSecret
|
||||||
};
|
};
|
||||||
|
|
||||||
var gNow = ((new Date()).getTime() / 1000).toFixed();
|
var gNow = ((new Date()).getTime() / 1000).toFixed();
|
||||||
|
var gEcosystem = null;
|
||||||
|
try {
|
||||||
|
gEcosystem = require(path.join(__dirname, '../keys/appstore/ecosystem-staging.json'));
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
function cloudronDomain(filename) {
|
function cloudronDomain(filename) {
|
||||||
return 't-' + path.basename(filename, '-test.js') + '-' + gNow + '.smartserver.io';
|
return 't-' + path.basename(filename, '-test.js') + '-' + gNow + '.smartserver.io';
|
||||||
@ -27,9 +33,12 @@ function verifyResponse(res, errorMessage) {
|
|||||||
|
|
||||||
function getOwner() {
|
function getOwner() {
|
||||||
return {
|
return {
|
||||||
username: process.env.APPSTORE_USERNAME || 'test',
|
username: process.env.APPSTORE_USERNAME || gEcosystem.APPSTORE_USERNAME,
|
||||||
password: process.env.APPSTORE_PASSWORD || 'test1234',
|
password: process.env.APPSTORE_PASSWORD || gEcosystem.APPSTORE_PASSWORD,
|
||||||
email: process.env.APPSTORE_EMAIL || 'test@cloudron.io'
|
email: process.env.APPSTORE_EMAIL || gEcosystem.APPSTORE_EMAIL
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stripeSecret() {
|
||||||
|
return process.env.STRIPE_SECRET;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user