Skip to content
This repository was archived by the owner on Feb 28, 2020. It is now read-only.

Commit 86a102f

Browse files
author
Jennifer Oliver
authored
Merge pull request #146 from ibm-developer/require-bluemix
fix: require bluemix option
2 parents e91763d + ea87187 commit 86a102f

File tree

2 files changed

+26
-44
lines changed

2 files changed

+26
-44
lines changed

app/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,15 @@ module.exports = class extends Generator {
5353
constructor(args, opts) {
5454
super(args, opts);
5555

56-
// bluemix option for YaaS integration
57-
this.argument(OPTION_BLUEMIX, {
56+
this.option(OPTION_BLUEMIX, {
5857
desc: 'Option for deploying with Bluemix. Stringified JSON.',
59-
required: false,
58+
required: true,
6059
hide: true,
6160
type: String
62-
});
61+
})
6362

6463
// spec as json
65-
this.argument(OPTION_SPEC, {
64+
this.option(OPTION_SPEC, {
6665
desc: 'The generator specification. Stringified JSON.',
6766
required: false,
6867
hide: true,
@@ -73,8 +72,9 @@ module.exports = class extends Generator {
7372
initializing() {
7473
this.skipPrompt = true;
7574
let bluemix_ok= this._sanitizeOption(this.options, OPTION_BLUEMIX);
76-
let spec_ok= this._sanitizeOption(this.options, OPTION_SPEC);
77-
if ( ! (bluemix_ok || spec_ok )) throw ("Must specify either bluemix or spec parameter");
75+
this._sanitizeOption(this.options, OPTION_SPEC)
76+
77+
if ( ! (bluemix_ok )) throw ("Must specify bluemix parameter");
7878

7979
if ( typeof this.options.bluemix.quiet == "undefined" || ! this.options.bluemix.quiet ) {
8080
logger.info("Package info ::", Bundle.name, Bundle.version);

test/integration.js

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,6 @@ const helpers = require('yeoman-test');
2323
const fs = require('fs');
2424
const PROJECT_NAME = "ProjectName";
2525

26-
27-
28-
29-
describe('error thrown when bluemix parameter is missing', function () {
30-
31-
before(function () {
32-
// Mock the options, set up an output folder and run the generator
33-
return helpers.run(path.join(__dirname, '../app'))
34-
.withOptions({}) // No parameters!!
35-
.on('error', function () {
36-
assert(true);
37-
})
38-
.toPromise( function() { // Should never return a promise
39-
assert(false)
40-
})
41-
});
42-
});
43-
4426
describe('core-node-express:app integration test with custom spec', function () {
4527
// Express build is slow so we need to set a longer timeout for the test
4628
this.timeout(150000);
@@ -49,8 +31,8 @@ describe('core-node-express:app integration test with custom spec', function ()
4931
// Mock the options, set up an output folder and run the generator
5032
return helpers.run(path.join(__dirname, '../app'))
5133
.withOptions({
52-
spec: JSON.stringify({ appname: 'testApp', port: common.defaultPort }),
53-
bluemix: JSON.stringify({ name: PROJECT_NAME })
34+
bluemix: JSON.stringify({ name: PROJECT_NAME }),
35+
spec: JSON.stringify({ appname: 'testApp', port: common.defaultPort })
5436
})
5537
.toPromise(); // Get a Promise back when the generator finishes
5638
});
@@ -67,8 +49,8 @@ describe('core-node-express:app integration test with custom spec', function ()
6749
});
6850

6951
describe('has a public directory', function () {
70-
// Files which we assert are created each time the app generator is run.
71-
// Takes an array of files, converted from obj by Object.values().
52+
// Files which we assert are created each time the app generator is run.
53+
// Takes an array of files, converted from obj by Object.values().
7254
it('creates public route', function () {
7355
assert.fileContent('server/routers/index.js', 'require(\'./public\')(app);');
7456
})
@@ -460,11 +442,11 @@ describe('core-node-express:app integration test as microservice', function () {
460442
this.timeout(150000);
461443
before(function () {
462444
return helpers.run(path.join(__dirname, '../app'))
463-
.withOptions({
464-
spec: JSON.stringify({ appname: 'testApp', port: common.defaultPort, applicationType: 'MS' }),
465-
bluemix: JSON.stringify({ name: PROJECT_NAME })
466-
})
467-
.toPromise(); // Get a Promise back when the generator finishes
445+
.withOptions({
446+
spec: JSON.stringify({ appname: 'testApp', port: common.defaultPort, applicationType: 'MS' }),
447+
bluemix: JSON.stringify({ name: PROJECT_NAME })
448+
})
449+
.toPromise(); // Get a Promise back when the generator finishes
468450
});
469451

470452
it('creates health route', function () {
@@ -484,11 +466,11 @@ describe('core-node-express:app microservice integration test with openApiServic
484466
let swagger = JSON.parse(fs.readFileSync(path.join(__dirname, '../test/resources/person_dino.json'), 'utf8'));
485467
let swagStr = JSON.stringify(swagger);
486468
return helpers.run(path.join(__dirname, '../app'))
487-
.withOptions({
488-
spec: JSON.stringify({ appname: 'testApp', port: common.defaultPort, isDeployableContainer: true, applicationType: 'MS' }),
489-
bluemix: JSON.stringify({ name: PROJECT_NAME, openApiServers: [{ spec: swagStr }] })
490-
})
491-
.toPromise(); // Get a Promise back when the generator finishes
469+
.withOptions({
470+
spec: JSON.stringify({ appname: 'testApp', port: common.defaultPort, isDeployableContainer: true, applicationType: 'MS' }),
471+
bluemix: JSON.stringify({ name: PROJECT_NAME, openApiServers: [{ spec: swagStr }] })
472+
})
473+
.toPromise(); // Get a Promise back when the generator finishes
492474
});
493475

494476
it('public route', function () {
@@ -504,11 +486,11 @@ describe('core-node-express:app blank integration test with openApiServices', fu
504486
let swagger = JSON.parse(fs.readFileSync(path.join(__dirname, '../test/resources/person_dino.json'), 'utf8'));
505487
let swagStr = JSON.stringify(swagger);
506488
return helpers.run(path.join(__dirname, '../app'))
507-
.withOptions({
508-
spec: JSON.stringify({ appname: 'testApp', port: common.defaultPort, isDeployableContainer: true, applicationType: 'BLANK' }),
509-
bluemix: JSON.stringify({ name: PROJECT_NAME, openApiServers: [{ spec: swagStr }] })
510-
})
511-
.toPromise(); // Get a Promise back when the generator finishes
489+
.withOptions({
490+
spec: JSON.stringify({ appname: 'testApp', port: common.defaultPort, isDeployableContainer: true, applicationType: 'BLANK' }),
491+
bluemix: JSON.stringify({ name: PROJECT_NAME, openApiServers: [{ spec: swagStr }] })
492+
})
493+
.toPromise(); // Get a Promise back when the generator finishes
512494
});
513495

514496
it('public route', function () {

0 commit comments

Comments
 (0)