@serverless/platform-sdk
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -18,3 +18,3 @@ 'use strict'; | ||
var _utils2 = _interopRequireDefault(_utils); | ||
var utils = _interopRequireWildcard(_utils); | ||
@@ -27,2 +27,4 @@ var _refreshToken = require('../login/refreshToken'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -38,3 +40,3 @@ | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(tenant, title) { | ||
var user, response, text, data; | ||
var user, response, data; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -48,3 +50,3 @@ while (1) { | ||
case 2: | ||
user = _utils2.default.getLoggedInUser(); | ||
user = utils.getLoggedInUser(); | ||
_context.next = 5; | ||
@@ -67,24 +69,14 @@ return (0, _isomorphicFetch2.default)(`${_config2.default.backendUrl}tenants/${tenant}/accessKeys`, { | ||
response = _context.sent; | ||
_context.next = 8; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 11; | ||
break; | ||
} | ||
_context.next = 9; | ||
return response.text(); | ||
case 9: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 11: | ||
_context.next = 13; | ||
case 8: | ||
_context.next = 10; | ||
return response.json(); | ||
case 13: | ||
case 10: | ||
data = _context.sent; | ||
return _context.abrupt('return', data.secretAccessKey); | ||
case 15: | ||
case 12: | ||
case 'end': | ||
@@ -135,3 +127,3 @@ return _context.stop(); | ||
case 6: | ||
user = _utils2.default.getLoggedInUser(); | ||
user = utils.getLoggedInUser(); | ||
@@ -138,0 +130,0 @@ // Check if in config file, return that next... |
@@ -7,8 +7,18 @@ 'use strict'; | ||
var _isomorphicFetch = require('isomorphic-fetch'); | ||
var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); | ||
var _config = require('../config'); | ||
var _config2 = _interopRequireDefault(_config); | ||
var _package = require('../../package.json'); | ||
var _utils = require('../utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
var fetch = require('isomorphic-fetch'); | ||
var platformConfig = require('../config'); | ||
var currentVersion = require('../../package.json').version; | ||
var slugifyApp = function slugifyApp(text) { | ||
@@ -22,3 +32,3 @@ return text.toString().toLowerCase().replace(/[^a-z0-9]+/g, '-') // Replace any run of disallowed chars with a hyphen | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) { | ||
var body, response, text; | ||
var body, response; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -34,3 +44,3 @@ while (1) { | ||
_context.next = 3; | ||
return fetch(`${platformConfig.backendUrl}tenants/${data.tenant}/applications`, { | ||
return (0, _isomorphicFetch2.default)(`${_config2.default.backendUrl}tenants/${data.tenant}/applications`, { | ||
method: 'POST', | ||
@@ -40,3 +50,3 @@ body, | ||
'Content-Type': 'application/json', | ||
'x-platform-version': currentVersion, | ||
'x-platform-version': _package.version, | ||
Authorization: `bearer ${data.token}` | ||
@@ -48,19 +58,9 @@ } | ||
response = _context.sent; | ||
_context.next = 6; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 9; | ||
break; | ||
} | ||
case 6: | ||
return _context.abrupt('return', response.json()); | ||
_context.next = 7; | ||
return response.text(); | ||
case 7: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 9: | ||
return _context.abrupt('return', response.json()); | ||
case 10: | ||
case 'end': | ||
@@ -67,0 +67,0 @@ return _context.stop(); |
@@ -7,14 +7,23 @@ 'use strict'; | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
var _isomorphicFetch = require('isomorphic-fetch'); | ||
var fetch = require('isomorphic-fetch'); | ||
var platformConfig = require('../config'); | ||
var currentVersion = require('../../package.json').version; | ||
var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); | ||
var _require = require('../accessKeys'), | ||
getAccessKeyForTenant = _require.getAccessKeyForTenant; | ||
var _config = require('../config'); | ||
var _config2 = _interopRequireDefault(_config); | ||
var _package = require('../../package.json'); | ||
var _accessKeys = require('../accessKeys'); | ||
var _utils = require('../utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
var getApp = function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) { | ||
var token, response, text; | ||
var token, response; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -32,3 +41,3 @@ while (1) { | ||
_context.next = 4; | ||
return getAccessKeyForTenant(data.tenant); | ||
return (0, _accessKeys.getAccessKeyForTenant)(data.tenant); | ||
@@ -40,7 +49,7 @@ case 4: | ||
_context.next = 7; | ||
return fetch(`${platformConfig.backendUrl}tenants/${data.tenant}/applications/${data.app}`, { | ||
return (0, _isomorphicFetch2.default)(`${_config2.default.backendUrl}tenants/${data.tenant}/applications/${data.app}`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'x-platform-version': currentVersion, | ||
'x-platform-version': _package.version, | ||
Authorization: `bearer ${token}` | ||
@@ -52,19 +61,9 @@ } | ||
response = _context.sent; | ||
_context.next = 10; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 13; | ||
break; | ||
} | ||
case 10: | ||
return _context.abrupt('return', response.json()); | ||
_context.next = 11; | ||
return response.text(); | ||
case 11: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 13: | ||
return _context.abrupt('return', response.json()); | ||
case 14: | ||
case 'end': | ||
@@ -71,0 +70,0 @@ return _context.stop(); |
@@ -7,16 +7,24 @@ 'use strict'; | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
var _isomorphicFetch = require('isomorphic-fetch'); | ||
/* | ||
* Create Deployment | ||
* - Creates a deployment record on the Serverless Enterprise Platform | ||
*/ | ||
var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); | ||
var fetch = require('isomorphic-fetch'); | ||
var currentVersion = require('../../package.json').version; | ||
var platformConfig = require('../config'); | ||
var _package = require('../../package.json'); | ||
var _config = require('../config'); | ||
var _config2 = _interopRequireDefault(_config); | ||
var _utils = require('../utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } /* | ||
* Create Deployment | ||
* - Creates a deployment record on the Serverless Enterprise Platform | ||
*/ | ||
var createDeployment = function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) { | ||
var body, response, text; | ||
var body, response; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -30,3 +38,3 @@ while (1) { | ||
_context.next = 3; | ||
return fetch(`${platformConfig.backendUrl}tenants/${data.tenant}/applications/${data.app}/services/${data.serviceName}/deployments`, // eslint-disable-line | ||
return (0, _isomorphicFetch2.default)(`${_config2.default.backendUrl}tenants/${data.tenant}/applications/${data.app}/services/${data.serviceName}/deployments`, // eslint-disable-line | ||
{ | ||
@@ -37,3 +45,3 @@ method: 'POST', | ||
'Content-Type': 'application/json', | ||
'x-platform-version': currentVersion, | ||
'x-platform-version': _package.version, | ||
Authorization: `bearer ${data.accessKey}` | ||
@@ -45,19 +53,9 @@ } | ||
response = _context.sent; | ||
_context.next = 6; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 9; | ||
break; | ||
} | ||
case 6: | ||
return _context.abrupt('return', response.json()); | ||
_context.next = 7; | ||
return response.text(); | ||
case 7: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 9: | ||
return _context.abrupt('return', response.json()); | ||
case 10: | ||
case 'end': | ||
@@ -64,0 +62,0 @@ return _context.stop(); |
@@ -7,11 +7,21 @@ 'use strict'; | ||
var _isomorphicFetch = require('isomorphic-fetch'); | ||
var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); | ||
var _config = require('../config'); | ||
var _config2 = _interopRequireDefault(_config); | ||
var _package = require('../../package.json'); | ||
var _utils = require('../utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
var fetch = require('isomorphic-fetch'); | ||
var platformConfig = require('../config'); | ||
var currentVersion = require('../../package.json').version; | ||
var updateDeployment = function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) { | ||
var body, response, text; | ||
var body, response; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -26,3 +36,3 @@ while (1) { | ||
_context.next = 3; | ||
return fetch(`${platformConfig.backendUrl}tenants/${data.tenant}/applications/${data.app}/services/${data.serviceName}/deployments/${data.deploymentId}`, { | ||
return (0, _isomorphicFetch2.default)(`${_config2.default.backendUrl}tenants/${data.tenant}/applications/${data.app}/services/${data.serviceName}/deployments/${data.deploymentId}`, { | ||
method: 'PUT', | ||
@@ -32,3 +42,3 @@ body: JSON.stringify(body), | ||
'Content-Type': 'application/json', | ||
'x-platform-version': currentVersion, | ||
'x-platform-version': _package.version, | ||
Authorization: `bearer ${data.accessKey}` | ||
@@ -40,19 +50,9 @@ } | ||
response = _context.sent; | ||
_context.next = 6; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 9; | ||
break; | ||
} | ||
case 6: | ||
return _context.abrupt('return', response.json()); | ||
_context.next = 7; | ||
return response.text(); | ||
case 7: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 9: | ||
return _context.abrupt('return', response.json()); | ||
case 10: | ||
case 'end': | ||
@@ -59,0 +59,0 @@ return _context.stop(); |
@@ -18,7 +18,7 @@ 'use strict'; | ||
var logout = require('./logout'); | ||
var credentials = require('./credentials'); | ||
var utils = require('./utils'); | ||
var logs = require('./logs'); | ||
var secrets = require('./secrets'); | ||
module.exports = Object.assign({}, service, deployments, apps, tenants, accessKeys, login, logout, credentials, utils, logs); | ||
module.exports = Object.assign({}, service, deployments, apps, tenants, accessKeys, login, logout, utils, logs, secrets); | ||
//# sourceMappingURL=index.js.map |
'use strict'; | ||
var _isomorphicFetch = require('isomorphic-fetch'); | ||
var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); | ||
var _config = require('../config'); | ||
var _config2 = _interopRequireDefault(_config); | ||
var _package = require('../../package.json'); | ||
var _utils = require('../utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
var fetch = require('isomorphic-fetch'); | ||
var platformConfig = require('../config'); | ||
var currentVersion = require('../../package.json').version; | ||
var getTokens = function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(code) { | ||
var body, response, text; | ||
var body, response; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -18,6 +28,6 @@ while (1) { | ||
code, | ||
redirect_uri: `${platformConfig.frontendUrl}callback` | ||
redirect_uri: `${_config2.default.frontendUrl}callback` | ||
}); | ||
_context.next = 3; | ||
return fetch(`${platformConfig.backendUrl}tokens`, { | ||
return (0, _isomorphicFetch2.default)(`${_config2.default.backendUrl}tokens`, { | ||
method: 'POST', | ||
@@ -27,3 +37,3 @@ body, | ||
'Content-Type': 'application/json', | ||
'x-platform-version': currentVersion | ||
'x-platform-version': _package.version | ||
} | ||
@@ -34,19 +44,9 @@ }); | ||
response = _context.sent; | ||
_context.next = 6; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 9; | ||
break; | ||
} | ||
case 6: | ||
return _context.abrupt('return', response.json()); | ||
_context.next = 7; | ||
return response.text(); | ||
case 7: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 9: | ||
return _context.abrupt('return', response.json()); | ||
case 10: | ||
case 'end': | ||
@@ -53,0 +53,0 @@ return _context.stop(); |
'use strict'; | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
var _express = require('express'); | ||
/* | ||
* Login | ||
* - Logs user in via CLI. | ||
* - Loads and updates data in user's .serverlessrc. | ||
*/ | ||
var _express2 = _interopRequireDefault(_express); | ||
var express = require('express'); | ||
var bodyParser = require('body-parser'); | ||
var cors = require('cors'); | ||
var querystring = require('querystring'); | ||
var jwtDecode = require('jwt-decode'); | ||
var currentSdkVersion = require('../../package.json').version; | ||
var utils = require('../utils'); | ||
var openBrowser = require('./openBrowser'); | ||
var _bodyParser = require('body-parser'); | ||
var _require = require('../accessKeys'), | ||
createAccessKeyForTenant = _require.createAccessKeyForTenant; | ||
var _bodyParser2 = _interopRequireDefault(_bodyParser); | ||
var getTokens = require('./getTokens'); | ||
var platformConfig = require('../config'); | ||
var _cors = require('cors'); | ||
var _cors2 = _interopRequireDefault(_cors); | ||
var _querystring = require('querystring'); | ||
var _querystring2 = _interopRequireDefault(_querystring); | ||
var _jwtDecode = require('jwt-decode'); | ||
var _jwtDecode2 = _interopRequireDefault(_jwtDecode); | ||
var _package = require('../../package.json'); | ||
var _utils = require('../utils'); | ||
var utils = _interopRequireWildcard(_utils); | ||
var _openBrowser = require('./openBrowser'); | ||
var _openBrowser2 = _interopRequireDefault(_openBrowser); | ||
var _accessKeys = require('../accessKeys'); | ||
var _getTokens = require('./getTokens'); | ||
var _getTokens2 = _interopRequireDefault(_getTokens); | ||
var _config = require('../config'); | ||
var _config2 = _interopRequireDefault(_config); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } /* | ||
* Login | ||
* - Logs user in via CLI. | ||
* - Loads and updates data in user's .serverlessrc. | ||
*/ | ||
var login = function () { | ||
@@ -46,15 +73,15 @@ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(tenant) { | ||
// Start local server to aide CLI sign-in/up | ||
app = express(); | ||
app = (0, _express2.default)(); | ||
app.use(bodyParser.json()); | ||
app.use(cors()); | ||
app.use(_bodyParser2.default.json()); | ||
app.use((0, _cors2.default)()); | ||
server = app.listen(8000); | ||
refreshToken = void 0; | ||
scope = ['openid', 'email_verified', 'email', 'profile', 'name', 'offline_access']; | ||
AUTH0_DOMAIN = platformConfig.auth0Domain; | ||
auth0Queries = querystring.stringify({ | ||
AUTH0_DOMAIN = _config2.default.auth0Domain; | ||
auth0Queries = _querystring2.default.stringify({ | ||
audience: `https://${AUTH0_DOMAIN}/userinfo`, | ||
response_type: 'code', | ||
client_id: platformConfig.auth0ClientId, | ||
redirect_uri: `${platformConfig.frontendUrl}callback`, | ||
client_id: _config2.default.auth0ClientId, | ||
redirect_uri: `${_config2.default.frontendUrl}callback`, | ||
scope: scope.join(' ') | ||
@@ -64,3 +91,3 @@ }); | ||
_context3.next = 14; | ||
return openBrowser(auth0Endpoint); | ||
return (0, _openBrowser2.default)(auth0Endpoint); | ||
@@ -89,3 +116,3 @@ case 14: | ||
_context.next = 4; | ||
return getTokens(req.query.code); | ||
return (0, _getTokens2.default)(req.query.code); | ||
@@ -103,5 +130,5 @@ case 4: | ||
}; | ||
tokensQueries = querystring.stringify(queriesObj); | ||
tokensQueries = _querystring2.default.stringify(queriesObj); | ||
res.redirect(`${platformConfig.frontendUrl}callback?${tokensQueries}`); | ||
res.redirect(`${_config2.default.frontendUrl}callback?${tokensQueries}`); | ||
res.end(); | ||
@@ -112,3 +139,3 @@ _context.next = 19; | ||
case 12: | ||
endLoginQueries = querystring.stringify({ | ||
endLoginQueries = _querystring2.default.stringify({ | ||
cli: 'true', | ||
@@ -118,3 +145,3 @@ cliLoginSuccessful: 'true' | ||
res.redirect(`${platformConfig.frontendUrl}?${endLoginQueries}`); | ||
res.redirect(`${_config2.default.frontendUrl}?${endLoginQueries}`); | ||
res.end(); | ||
@@ -149,3 +176,3 @@ server.close(); | ||
// Update user's config file (.serverlessrc) | ||
decoded = jwtDecode(data.idToken); | ||
decoded = (0, _jwtDecode2.default)(data.idToken); | ||
id = decoded.tracking_id || decoded.sub; | ||
@@ -169,3 +196,3 @@ | ||
configFile.users[id].enterprise = configFile.users[id].enterprise || {}; | ||
configFile.users[id].enterprise.versionSDK = currentSdkVersion; | ||
configFile.users[id].enterprise.versionSDK = _package.version; | ||
configFile.users[id].enterprise.timeLastLogin = Math.round(+new Date() / 1000); | ||
@@ -186,3 +213,3 @@ | ||
_context2.next = 14; | ||
return createAccessKeyForTenant(tenant); | ||
return (0, _accessKeys.createAccessKeyForTenant)(tenant); | ||
@@ -189,0 +216,0 @@ case 14: |
'use strict'; | ||
/* eslint-disable no-console */ | ||
var _opn = require('opn'); | ||
var opn = require('opn'); | ||
var chalk = require('chalk'); | ||
var isDockerContainer = require('is-docker'); | ||
var _opn2 = _interopRequireDefault(_opn); | ||
var _chalk = require('chalk'); | ||
var _chalk2 = _interopRequireDefault(_chalk); | ||
var _isDocker = require('is-docker'); | ||
var _isDocker2 = _interopRequireDefault(_isDocker); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function displayManualOpenMessage(url, err) { | ||
@@ -14,12 +22,12 @@ // https://github.com/sindresorhus/log-symbols | ||
var msg = `Unable to open browser automatically${errMsg}`; | ||
console.log(`🙈 ${chalk.red(msg)}`); | ||
console.log(chalk.green('Please open your browser & open the URL below to login:')); | ||
console.log(chalk.yellow(url)); | ||
console.log(`🙈 ${_chalk2.default.red(msg)}`); | ||
console.log(_chalk2.default.green('Please open your browser & open the URL below to login:')); | ||
console.log(_chalk2.default.yellow(url)); | ||
console.log('---------------------------'); | ||
return false; | ||
} | ||
} /* eslint-disable no-console */ | ||
module.exports = function openBrowser(url) { | ||
var browser = process.env.BROWSER; | ||
if (browser === 'none' || isDockerContainer()) { | ||
if (browser === 'none' || (0, _isDocker2.default)()) { | ||
return displayManualOpenMessage(url); | ||
@@ -31,3 +39,3 @@ } | ||
var options = { wait: false, app: browser }; | ||
return opn(url, options).catch(function (err) { | ||
return (0, _opn2.default)(url, options).catch(function (err) { | ||
return displayManualOpenMessage(url, err); | ||
@@ -34,0 +42,0 @@ }); |
@@ -13,6 +13,8 @@ 'use strict'; | ||
var _utils2 = _interopRequireDefault(_utils); | ||
var utils = _interopRequireWildcard(_utils); | ||
var _package = require('../../package.json'); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -24,3 +26,3 @@ | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { | ||
var configFile, currentId, body, response, text, tokens, expiresAt; | ||
var configFile, currentId, body, response, tokens, expiresAt; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -30,3 +32,3 @@ while (1) { | ||
case 0: | ||
configFile = _utils2.default.readConfigFile(); | ||
configFile = utils.readConfigFile(); | ||
currentId = configFile.userId; | ||
@@ -57,20 +59,10 @@ | ||
response = _context.sent; | ||
_context.next = 10; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 13; | ||
break; | ||
} | ||
_context.next = 11; | ||
return response.text(); | ||
case 11: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 13: | ||
_context.next = 15; | ||
case 10: | ||
_context.next = 12; | ||
return response.json(); | ||
case 15: | ||
case 12: | ||
tokens = _context.sent; | ||
@@ -82,5 +74,5 @@ expiresAt = tokens.expires_in * 1000 + Date.now(); | ||
configFile.users[currentId].dashboard.expiresAt = expiresAt; | ||
_utils2.default.writeConfigFile(configFile); | ||
utils.writeConfigFile(configFile); | ||
case 21: | ||
case 18: | ||
case 'end': | ||
@@ -87,0 +79,0 @@ return _context.stop(); |
'use strict'; | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
var _package = require('../../package.json'); | ||
/* | ||
* Logout | ||
* - Logs user out. | ||
* - Loads and updates data in user's .serverlessrc. | ||
*/ | ||
var _utils = require('../utils'); | ||
var currentSdkVersion = require('../../package.json').version; | ||
var utils = require('../utils'); | ||
var utils = _interopRequireWildcard(_utils); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } /* | ||
* Logout | ||
* - Logs user out. | ||
* - Loads and updates data in user's .serverlessrc. | ||
*/ | ||
var logout = function () { | ||
@@ -46,3 +49,3 @@ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { | ||
loggedInUser.enterprise = loggedInUser.enterprise || {}; | ||
loggedInUser.enterprise.versionSDK = currentSdkVersion; | ||
loggedInUser.enterprise.versionSDK = _package.version; | ||
loggedInUser.enterprise.timeLastLogout = Math.round(+new Date() / 1000); | ||
@@ -49,0 +52,0 @@ } |
@@ -15,2 +15,4 @@ 'use strict'; | ||
var _utils = require('../utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -29,3 +31,3 @@ | ||
accessKey = _ref.accessKey; | ||
var body, response, text; | ||
var body, response; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -55,19 +57,9 @@ while (1) { | ||
response = _context.sent; | ||
_context.next = 6; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 9; | ||
break; | ||
} | ||
case 6: | ||
return _context.abrupt('return', response.json()); | ||
_context.next = 7; | ||
return response.text(); | ||
case 7: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 9: | ||
return _context.abrupt('return', response.json()); | ||
case 10: | ||
case 'end': | ||
@@ -74,0 +66,0 @@ return _context.stop(); |
@@ -15,2 +15,4 @@ 'use strict'; | ||
var _utils = require('../utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -28,3 +30,3 @@ | ||
accessKey = _ref.accessKey; | ||
var body, response, text; | ||
var body, response; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -53,19 +55,9 @@ while (1) { | ||
response = _context.sent; | ||
_context.next = 6; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 9; | ||
break; | ||
} | ||
case 6: | ||
return _context.abrupt('return'); | ||
_context.next = 7; | ||
return response.text(); | ||
case 7: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 9: | ||
return _context.abrupt('return'); | ||
case 10: | ||
case 'end': | ||
@@ -72,0 +64,0 @@ return _context.stop(); |
@@ -7,11 +7,21 @@ 'use strict'; | ||
var _isomorphicFetch = require('isomorphic-fetch'); | ||
var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); | ||
var _config = require('../config'); | ||
var _config2 = _interopRequireDefault(_config); | ||
var _package = require('../../package.json'); | ||
var _utils = require('../utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
var fetch = require('isomorphic-fetch'); | ||
var platformConfig = require('../config'); | ||
var currentVersion = require('../../package.json').version; | ||
var archiveService = function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) { | ||
var body, response, text; | ||
var body, response; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -26,3 +36,3 @@ while (1) { | ||
_context.next = 3; | ||
return fetch(`${platformConfig.backendUrl}tenants/${data.tenant}/applications/${data.app}/services/${data.name}`, { | ||
return (0, _isomorphicFetch2.default)(`${_config2.default.backendUrl}tenants/${data.tenant}/applications/${data.app}/services/${data.name}`, { | ||
method: 'PUT', | ||
@@ -32,3 +42,3 @@ body: JSON.stringify(body), | ||
'Content-Type': 'application/json', | ||
'x-platform-version': currentVersion, | ||
'x-platform-version': _package.version, | ||
Authorization: `bearer ${data.accessKey}` | ||
@@ -40,19 +50,9 @@ } | ||
response = _context.sent; | ||
_context.next = 6; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 9; | ||
break; | ||
} | ||
case 6: | ||
return _context.abrupt('return', response.json()); | ||
_context.next = 7; | ||
return response.text(); | ||
case 7: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 9: | ||
return _context.abrupt('return', response.json()); | ||
case 10: | ||
case 'end': | ||
@@ -59,0 +59,0 @@ return _context.stop(); |
@@ -6,6 +6,11 @@ 'use strict'; | ||
}); | ||
var platformConfig = require('../config'); | ||
var _config = require('../config'); | ||
var _config2 = _interopRequireDefault(_config); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var getServiceUrl = function getServiceUrl(data) { | ||
return `${platformConfig.frontendUrl}tenants/${data.tenant}/applications/${data.app}/services/${data.name}`; | ||
return `${_config2.default.frontendUrl}tenants/${data.tenant}/applications/${data.app}/services/${data.name}`; | ||
}; | ||
@@ -12,0 +17,0 @@ |
@@ -7,11 +7,21 @@ 'use strict'; | ||
var _isomorphicFetch = require('isomorphic-fetch'); | ||
var _isomorphicFetch2 = _interopRequireDefault(_isomorphicFetch); | ||
var _config = require('../config'); | ||
var _config2 = _interopRequireDefault(_config); | ||
var _package = require('../../package.json'); | ||
var _utils = require('../utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
var fetch = require('isomorphic-fetch'); | ||
var platformConfig = require('../config'); | ||
var currentVersion = require('../../package.json').version; | ||
var listTenants = function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) { | ||
var response, text; | ||
var response; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -22,7 +32,7 @@ while (1) { | ||
_context.next = 2; | ||
return fetch(`${platformConfig.backendUrl}tenants?userName=${data.username}`, { | ||
return (0, _isomorphicFetch2.default)(`${_config2.default.backendUrl}tenants?userName=${data.username}`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'x-platform-version': currentVersion, | ||
'x-platform-version': _package.version, | ||
Authorization: `bearer ${data.idToken}` | ||
@@ -34,19 +44,9 @@ } | ||
response = _context.sent; | ||
_context.next = 5; | ||
return (0, _utils.checkHttpResponse)(response); | ||
if (response.ok) { | ||
_context.next = 8; | ||
break; | ||
} | ||
case 5: | ||
return _context.abrupt('return', response.json()); | ||
_context.next = 6; | ||
return response.text(); | ||
case 6: | ||
text = _context.sent; | ||
throw new Error(text); | ||
case 8: | ||
return _context.abrupt('return', response.json()); | ||
case 9: | ||
case 'end': | ||
@@ -53,0 +53,0 @@ return _context.stop(); |
'use strict'; | ||
var configFile = require('./configFile'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
module.exports = Object.assign({}, configFile); | ||
var _configFile = require('./configFile'); | ||
Object.keys(_configFile).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _configFile[key]; | ||
} | ||
}); | ||
}); | ||
var _checkHttpResponse = require('./checkHttpResponse'); | ||
Object.defineProperty(exports, 'checkHttpResponse', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_checkHttpResponse).default; | ||
} | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@serverless/platform-sdk", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Serverless Platform SDK", | ||
@@ -5,0 +5,0 @@ "author": "Serverless, Inc.", |
@@ -7,3 +7,3 @@ # Platform SDK | ||
[![Build Status](https://travis-ci.org/serverless/platform-sdk.svg)](https://travis-ci.org/serverless/platform-sdk) | ||
[![Build Status](https://travis-ci.com/serverless/platform-sdk.svg)](https://travis-ci.com/serverless/platform-sdk) | ||
[![license](https://img.shields.io/npm/l/@serverless/platform-sdk.svg)](https://www.npmjs.com/package/@serverless/platform-sdk) | ||
@@ -10,0 +10,0 @@ [![coverage](https://img.shields.io/codecov/c/github/serverless/platform-sdk.svg)](https://codecov.io/gh/serverless/platform-sdk) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
134291
63
1365
0