Skip to content
This repository was archived by the owner on Feb 28, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

'use strict';
const Generator = require('yeoman-generator');
const Bundle = require("./../package.json")
const Bundle = require("./../package.json");
const Log4js = require('log4js');
const logger = Log4js.getLogger("generator-core-node-express");
const helpers = require('../lib/helpers');
Expand All @@ -28,7 +28,10 @@ module.exports = class extends Generator {

constructor(args, opts) {
super(args, opts);
logger.info("Package info ::", Bundle.name, Bundle.version);

if ( typeof opts.bluemix.quiet == "undefined" || ! opts.bluemix.quiet ) {
logger.info("Package info ::", Bundle.name, Bundle.version);
}

// bluemix option for YaaS integration
this.argument(OPTION_BLUEMIX, {
Expand Down Expand Up @@ -127,8 +130,8 @@ module.exports = class extends Generator {
this.fs.delete(this.destinationPath('server/routers/swagger.js'));
}

// microservice does not serve up default page
if(this.options.spec && this.options.spec.applicationType === 'MS') {
// if there is swagger, there is no index page
if( this.options.genSwagger ) {
this.fs.delete(this.destinationPath('server/routers/public.js'));
}
else {
Expand All @@ -154,7 +157,7 @@ module.exports = class extends Generator {
return false;
}

if (optionValue.indexOf("file:") === 0) {
if (typeof optionValue === "string" && optionValue.indexOf("file:") === 0) {
let fileName = optionValue.replace("file:", "");
let filePath = this.destinationPath("./" + fileName);
logger.info("Reading", name, "parameter from local file", filePath);
Expand Down
2 changes: 2 additions & 0 deletions app/templates/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
node_modules_linux/
4 changes: 0 additions & 4 deletions app/templates/Dockerfile-tools
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ ENV PORT 3000

WORKDIR "/app"

# Install app dependencies
COPY package.json /app/
RUN cd /app; npm install

# Bundle app source
COPY . /app

Expand Down
2 changes: 1 addition & 1 deletion app/templates/server/routers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function(app){
if( genSwagger ){ %>
require('./swagger')(app);
<% }
if ( typeof spec === 'undefined' || (typeof spec !== 'undefined' && spec.applicationType !== 'MS')) {%>
if ( !parsedSwagger ) {%>
require('./public')(app);
<% }
if(typeof spec === 'undefined' || spec.applicationType !== 'BLANK'){ %>
Expand Down
7 changes: 5 additions & 2 deletions app/templates/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ require('./routers/index')(app);

const port = process.env.PORT || localConfig.port;
app.listen(port, function(){
logger.info(`<%= bluemix.name %> listening on http://localhost:${port}/appmetrics-dash`);
<% if( !genSwagger ){ %>
logger.info(`<%= bluemix.name %> listening on http://localhost:${port}`);
<% if(typeof spec !== 'undefined' && spec.applicationType === 'MS'){ %>
<% } %>
<% if( genSwagger ){ %>
logger.info(`OpenAPI (Swagger) spec is available at http://localhost:${port}/swagger/api`);
logger.info(`Swagger UI is available at http://localhost:${port}/explorer`);
<% } %>
});
});