Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

loopback-bluemix

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loopback-bluemix - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

16

lib/cf.js

@@ -146,10 +146,13 @@ // Copyright IBM Corp. 2017. All Rights Reserved.

/**
* Load ~/.cf/config.json
* @returns {*}
* Load Cloud Foundry config file
* @param configFilePath {string} Path to CF config file
* @returns {object}
*/
function getCfConfig() {
var home = os.homedir();
var cfConfig = {};
function getCfConfig(configFilePath) {
if (!configFilePath) {
var home = os.homedir();
configFilePath = path.join(home, '.cf', 'config.json');
}
try {
cfConfig = require(path.join(home, '.cf/config.json'));
var cfConfig = require(configFilePath);
} catch (e) {

@@ -419,3 +422,2 @@ console.error('Please use `cf login` to log into Bluemix first.');

/**

@@ -422,0 +424,0 @@ * Bind a service to an app

{
"name": "loopback-bluemix",
"version": "1.0.0",
"version": "1.1.0",
"description": "Utilities for generating generate Bluemix artefacts",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -21,67 +21,79 @@ // Copyright IBM Corp. 2014,2016. All Rights Reserved.

var cf = lbBM.cf;
var accessToken = cf.getCfConfig().accessToken;
var cfConfig = cf.getCfConfig();
describe('lib/cf', function() {
it('should get apps', function(done) {
cf.getApps(null, accessToken, function(err, apps) {
assert(!err);
var appFound = false;
apps.forEach(function(app) {
if (cfTestConfig.app.name === app.entity.name) {
appFound = true;
}
if (Object.keys(cfConfig).length) {
var accessToken = cfConfig.accessToken;
describe('lib/cf', function() {
it('should get CF config', function() {
var cfConfig = cf.getCfConfig();
assert('organization' in cfConfig);
assert('space' in cfConfig);
assert('apiURL' in cfConfig);
assert('accessToken' in cfConfig);
});
it('should get apps', function(done) {
cf.getApps(null, accessToken, function(err, apps) {
assert(!err);
var appFound = false;
apps.forEach(function(app) {
if (cfTestConfig.app.name === app.entity.name) {
appFound = true;
}
});
assert(appFound);
done();
});
assert(appFound);
done();
});
});
it('should get service instances', function(done) {
cf.getServiceInstances(null, accessToken, function(err, services) {
assert(!err);
var state = getServiceState(services);
assert(state.supportedServiceFound);
assert(state.unsupportedServiceFound);
assert(state.nondataServiceFound);
done();
it('should get service instances', function(done) {
cf.getServiceInstances(null, accessToken, function(err, services) {
assert(!err);
var state = getServiceState(services);
assert(state.supportedServiceFound);
assert(state.unsupportedServiceFound);
assert(state.nondataServiceFound);
done();
});
});
});
it('should get only data service instances', function(done) {
cf.getDataServiceInstances(null, accessToken, function(err, services) {
assert(!err);
var state = getServiceState(services);
assert(state.supportedServiceFound);
assert(state.unsupportedServiceFound);
assert(!state.nondataServiceFound);
done();
it('should get only data service instances', function(done) {
cf.getDataServiceInstances(null, accessToken, function(err, services) {
assert(!err);
var state = getServiceState(services);
assert(state.supportedServiceFound);
assert(state.unsupportedServiceFound);
assert(!state.nondataServiceFound);
done();
});
});
});
});
function getServiceState(services) {
var state = {
supportedServiceFound: false,
unsupportedServiceFound: false,
nondataServiceFound: false,
};
function getServiceState(services) {
var state = {
supportedServiceFound: false,
unsupportedServiceFound: false,
nondataServiceFound: false,
};
services.forEach(function(service) {
var supportedService = cfTestConfig.service.supported;
var unsupportedService = cfTestConfig.service.unsupported;
var nondataService = cfTestConfig.service.nondata;
var serviceName = service.instance.entity.name;
var serviceGuid = service.instance.metadata.guid;
if (supportedService.name === serviceName &&
supportedService.guid === serviceGuid) {
state.supportedServiceFound = true;
} else if (unsupportedService.name === serviceName &&
unsupportedService.guid === serviceGuid) {
state.unsupportedServiceFound = true;
} else if (nondataService.name === serviceName &&
nondataService.guid === serviceGuid) {
state.nondataServiceFound = true;
}
});
return state;
services.forEach(function(service) {
var supportedService = cfTestConfig.service.supported;
var unsupportedService = cfTestConfig.service.unsupported;
var nondataService = cfTestConfig.service.nondata;
var serviceName = service.instance.entity.name;
var serviceGuid = service.instance.metadata.guid;
if (supportedService.name === serviceName &&
supportedService.guid === serviceGuid) {
state.supportedServiceFound = true;
} else if (unsupportedService.name === serviceName &&
unsupportedService.guid === serviceGuid) {
state.unsupportedServiceFound = true;
} else if (nondataService.name === serviceName &&
nondataService.guid === serviceGuid) {
state.nondataServiceFound = true;
}
});
return state;
}
}

@@ -15,2 +15,3 @@ // Copyright IBM Corp. 2014,2016. All Rights Reserved.

var lbBM = require(path.resolve(__dirname, '..'));
var cfConfig = lbBM.cf.getCfConfig();
var sandboxDir = path.resolve(__dirname, 'sandbox');

@@ -79,17 +80,19 @@ var fixturesDir = path.resolve(__dirname, 'fixtures');

it('should configure a Bluemix datasource selection', function(done) {
datasource.async = function() {
return function() {
assert('cloudant-service' === datasource.name);
assert('cloudant' === datasource.connector);
assert('serviceGUID' in datasource);
done();
if (Object.keys(cfConfig).length) {
it('should configure a Bluemix datasource selection', function(done) {
datasource.async = function() {
return function() {
assert('cloudant-service' === datasource.name);
assert('cloudant' === datasource.connector);
assert('serviceGUID' in datasource);
done();
};
};
};
datasource.log = console.log;
datasource.prompt = generatePrompt({
serviceName: 'cloudant-service',
datasource.log = console.log;
datasource.prompt = generatePrompt({
serviceName: 'cloudant-service',
});
lbBM.ds.selectBluemixDatasource(datasource, globalize);
});
lbBM.ds.selectBluemixDatasource(datasource, globalize);
});
}

@@ -111,11 +114,13 @@ it('should configure new service provision', function(done) {

it('should get service plans', function(done) {
datasource.async = function() {
return function() {
assert('cloudantNoSQLDB' in datasource.dataServices);
done();
if (Object.keys(cfConfig).length) {
it('should get service plans', function(done) {
datasource.async = function() {
return function() {
assert('cloudantNoSQLDB' in datasource.dataServices);
done();
};
};
};
lbBM.ds.getServicePlans(datasource);
});
lbBM.ds.getServicePlans(datasource);
});
}

@@ -122,0 +127,0 @@ it('should update datasources-config.json', function(done) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc