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';
|
||||
|
||||
var debug = require('debug')('e2e:appstore'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
var common = require('./common.js'),
|
||||
debug = require('debug')('e2e:appstore'),
|
||||
request = require('superagent-sync'),
|
||||
sleep = require('sleep').sleep,
|
||||
stripe = require('stripe');
|
||||
@ -17,12 +16,6 @@ function AppStore(origin) {
|
||||
password: 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) {
|
||||
@ -106,7 +99,7 @@ AppStore.prototype.restore = function (boxId, backupId) {
|
||||
};
|
||||
|
||||
AppStore.prototype.setupBilling = function (callback) {
|
||||
var stripeApi = stripe(this._ecosystem.env['STRIPE_SECRET']);
|
||||
var stripeApi = stripe(common.stripeSecret());
|
||||
|
||||
var that = this;
|
||||
|
||||
|
15
common.js
15
common.js
@ -9,9 +9,15 @@ exports = module.exports = {
|
||||
cloudronDomain: cloudronDomain,
|
||||
verifyResponse: verifyResponse,
|
||||
getOwner: getOwner,
|
||||
stripeSecret: stripeSecret
|
||||
};
|
||||
|
||||
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) {
|
||||
return 't-' + path.basename(filename, '-test.js') + '-' + gNow + '.smartserver.io';
|
||||
@ -27,9 +33,12 @@ function verifyResponse(res, errorMessage) {
|
||||
|
||||
function getOwner() {
|
||||
return {
|
||||
username: process.env.APPSTORE_USERNAME || 'test',
|
||||
password: process.env.APPSTORE_PASSWORD || 'test1234',
|
||||
email: process.env.APPSTORE_EMAIL || 'test@cloudron.io'
|
||||
username: process.env.APPSTORE_USERNAME || gEcosystem.APPSTORE_USERNAME,
|
||||
password: process.env.APPSTORE_PASSWORD || gEcosystem.APPSTORE_PASSWORD,
|
||||
email: process.env.APPSTORE_EMAIL || gEcosystem.APPSTORE_EMAIL
|
||||
};
|
||||
}
|
||||
|
||||
function stripeSecret() {
|
||||
return process.env.STRIPE_SECRET;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user