'use strict'; var path = require('path'), safe = require('safetydance'), _ = require('underscore'); exports = module.exports = { TESTAPP_ID: 'io.cloudron.testapp', TESTAPP_VERSION : '1.0.3', cloudronDomain: cloudronDomain, verifyResponse: verifyResponse, getOwner: getOwner, stripeSecret: stripeSecret, stripUnreachable: stripUnreachable }; var gNow = ((new Date()).getTime() / 1000).toFixed(); var gEcosystem = safe.require(path.join(__dirname, '../keys/ci/ecosystem-prod.json')); function cloudronDomain(filename) { return 't-' + path.basename(filename, '-test.js') + '-' + gNow + '.smartserver.io'; } function stripUnreachable(releases) { var reachableVersions = [ ]; var curVersion = '0.0.1'; while (true) { reachableVersions.push(curVersion); var nextVersion = releases[curVersion].next; if (!nextVersion) break; curVersion = nextVersion; } return _.pick(releases, reachableVersions); } function verifyResponse2(res, errorMessage) { if (res.statusCode < 200 || res.statusCode > 399) { debug('Response error statusCode:%s error:%s body:%j', res.statusCode, res.error, res.body); debug(errorMessage.red); throw new Error(errorMessage); } } function verifyResponse(res, errorMessage) { if (res.statusCode < 200 || res.statusCode > 299) { console.log('Response error statusCode:%s error:%s body:%s', res.statusCode, res.error, res.body); console.log(errorMessage.red); process.exit(1); } } function getOwner() { return { username: process.env.APPSTORE_USERNAME || gEcosystem.env.APPSTORE_USERNAME, password: process.env.APPSTORE_PASSWORD || gEcosystem.env.APPSTORE_PASSWORD, email: process.env.APPSTORE_EMAIL || gEcosystem.env.APPSTORE_EMAIL }; } function stripeSecret() { return process.env.STRIPE_SECRET || gEcosystem.env.STRIPE_SECRET; }