-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update generator js #6
Changes from 25 commits
1b51f4f
f910855
15237d3
1ad8a76
a75ee95
087513f
d9f8e42
9292031
879c851
eef7f2c
d15dab0
466189e
f6fdfbe
60d1e11
87421c3
f13d61f
df641fe
47c0c8f
bc8888c
3dc802a
05b0fa4
0176fb7
9387e86
6d66bee
0ca01a7
23d7f83
ee14c2a
422b41c
248ae72
2316a86
d90b2b5
ebb69c2
832871f
590357c
5167bf0
2a5bd50
dcc9d10
9758328
22ccfd7
e64fb18
cd42d5b
c560bd7
89049fe
2581acf
5bab2b7
c3792df
f71e05c
3ac2234
cd500c6
d3c4e55
94de1e8
df66084
70e0a17
c7389a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"enablePrompts":true, | ||
"mediatorName":"Yeoman Generated Mediator", | ||
"mediatorDesc":"Brief Description", | ||
"mediatorAuthor":"Jembi Health Systems NPC", | ||
"mediatorMaintainer":"Name Surname <email@exchange.com> (https://github.com/githubusername)", | ||
"configPort":7000, | ||
"defaultChannelPath":"channelPath", | ||
"mediatorRouteHost":"localhost", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should just be |
||
"mediatorRoutePath":"routePath", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that instead of setting a routePath the mediator should rather accept all requests. Like the following: app.all(mediatorConfig.endpoints[0].path, (req, res) => {
console.log(`Processing ${req.method} request on ${mediatorConfig.endpoints[0].path}`) |
||
|
||
"configureApi": false, | ||
"mediatorApiUsername":"root@openhim.org", | ||
"mediatorApiPassword":"password", | ||
"mediatorApiUrl":"https://localhost:8080", | ||
"mediatorApiSsl":true, | ||
"mediatorRegister":true, | ||
|
||
"enablePPA":false, | ||
"ppaUsername":"rg-crichton" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change this default to |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,117 @@ | ||
'use strict'; | ||
'use strict' | ||
|
||
var util = require('util'); | ||
var path = require('path'); | ||
var yeoman = require('yeoman-generator'); | ||
var chalk = require('chalk'); | ||
var yosay = require('yosay'); | ||
var uuid = require('node-uuid'); | ||
var generator = require('yeoman-generator') | ||
var chalk = require('chalk') | ||
var yosay = require('yosay') | ||
var uuid = require('node-uuid') | ||
|
||
var mediatorJsGenerator = yeoman.generators.Base.extend({ | ||
|
||
prompting: function () { | ||
var done = this.async(); | ||
|
||
// Have Yeoman greet the user. | ||
this.log(yosay( | ||
'Welcome to the marvelous ' + chalk.red('MediatorJs') + ' generator!' | ||
)); | ||
|
||
var prompts = [{ | ||
type: 'input', | ||
name: 'mediatorName', | ||
message: 'What is your Mediator\'s name?', | ||
default: 'Yeoman Generated Mediator', | ||
validate: function(mediatorName){ | ||
if(mediatorName !== ''){ return true; }else{ return 'Please supply a Mediator Name'; } | ||
} | ||
}, { | ||
type: 'input', | ||
name: 'mediatorDesc', | ||
message: 'What does your Mediator do?', | ||
default: 'Brief Description' | ||
}, { | ||
type: 'input', | ||
name: 'configPort', | ||
message: 'Under what port number should the mediator run?', | ||
default: 3000 | ||
}, { | ||
type: 'input', | ||
name: 'mediatorRoutePath', | ||
message: 'What is your primary route path?' | ||
}]; | ||
var prompts = require('./prompts') | ||
var config = require('./config') | ||
|
||
this.prompt(prompts, function (props) { | ||
this.configPort = props.configPort; | ||
this.mediatorName = props.mediatorName; | ||
this.mediatorDesc = props.mediatorDesc; | ||
this.mediatorRoutePath = props.mediatorRoutePath; | ||
var mediatorJsGenerator = generator.Base.extend({ | ||
constructor: function () { | ||
generator.Base.apply(this, arguments) | ||
|
||
done(); | ||
}.bind(this)); | ||
this.option('useDefaults') | ||
this.enablePrompts = (this.options.useDefaults ? false : true) | ||
}, | ||
|
||
scaffoldFolders: function(){ | ||
this.mkdir("app/config"); | ||
this.mkdir("build"); | ||
|
||
prompting: function () { | ||
return this.prompt(prompts.promptsList(this.enablePrompts)).then(function (props) { | ||
// Mediator settings | ||
this.mediatorName = props.mediatorName || config.mediatorName | ||
this.mediatorDesc = props.mediatorDesc || config.mediatorDesc | ||
this.mediatorAuthor = props.mediatorAuthor || config.mediatorAuthor | ||
this.mediatorMaintainer = props.mediatorMaintainer || config.mediatorMaintainer | ||
this.configPort = props.configPort || config.configPort | ||
this.defaultChannelPath = props.defaultChannelPath || config.defaultChannelPath | ||
this.mediatorRoutePath = props.mediatorRoutePath || config.mediatorRoutePath | ||
this.mediatorRouteHost = props.mediatorRouteHost || config.mediatorRouteHost | ||
|
||
// API settings | ||
this.configureApi = props.configureApi || config.configureApi | ||
this.mediatorApiUsername = props.mediatorApiUsername || config.mediatorApiUsername | ||
this.mediatorApiPassword = props.mediatorApiPassword || config.mediatorApiPassword | ||
this.mediatorApiUrl = props.mediatorApiUrl || config.mediatorApiUrl | ||
this.mediatorApiSsl = props.mediatorApiSsl || config.mediatorApiSsl | ||
this.mediatorRegister = props.mediatorRegister || config.mediatorRegister | ||
|
||
// PPA settings | ||
this.enablePPA = props.enablePPA || config.enablePPA | ||
this.ppaUsername = props.ppaUsername || config.ppaUsername | ||
}.bind(this)) | ||
}, | ||
|
||
copyMainFiles: function(){ | ||
|
||
var context = { | ||
writing: function() { | ||
// Set up context objects to populate templates | ||
var mediatorContext = { | ||
configPort: this.configPort, | ||
mediatorUUID: "urn:uuid:"+uuid.v1(), | ||
mediatorUUID: "urn:uuid:" + uuid.v1(), | ||
appName: this.mediatorName.replace(/ /g,"-"), | ||
mediatorName: this.mediatorName, | ||
mediatorDesc: this.mediatorDesc, | ||
mediatorRoutePath: this.mediatorRoutePath, | ||
}; | ||
|
||
this.template("_gruntfile.js", "Gruntfile.js", context); | ||
this.template("_package.json", "package.json", context); | ||
this.template("_mediator.json", "app/config/mediator.json", context); | ||
|
||
this.copy("_config.json", "app/config/config.json"); | ||
this.copy("_index.js", "app/index.js"); | ||
this.copy("_register.js", "app/register.js"); | ||
mediatorAuthor: this.mediatorAuthor, | ||
mediatorMaintainer: this.mediatorMaintainer, | ||
defaultChannelPath: this.defaultChannelPath, | ||
mediatorRouteHost: this.mediatorRouteHost, | ||
mediatorRoutePath: this.mediatorRoutePath | ||
} | ||
|
||
var apiContext = { | ||
mediatorApiUsername: this.mediatorApiUsername, | ||
mediatorApiPassword: this.mediatorApiPassword, | ||
mediatorApiUrl: this.mediatorApiUrl, | ||
mediatorApiSsl: this.mediatorApiSsl, | ||
mediatorRegister: this.mediatorRegister | ||
} | ||
|
||
var ppaContext = { | ||
ppaUsername: this.ppaUsername, | ||
mediatorName: this.mediatorName, | ||
appName: this.mediatorName.replace(/ /g,"-"), | ||
mediatorMaintainer: this.mediatorMaintainer, | ||
mediatorDesc: this.mediatorDesc | ||
} | ||
|
||
// Add the mediator files | ||
this.fs.copyTpl(this.templatePath('mediatorTemplate/_package.json'), this.destinationPath('package.json'), mediatorContext) | ||
this.fs.copyTpl(this.templatePath('mediatorTemplate/config/_mediator.json'), this.destinationPath('config/mediator.json'), mediatorContext) | ||
this.fs.copyTpl(this.templatePath('mediatorTemplate/config/_config.json'), this.destinationPath('config/config.json'), apiContext) | ||
this.fs.copyTpl(this.templatePath('mediatorTemplate/lib/_index.js'), this.destinationPath('lib/index.js')) | ||
this.fs.copyTpl(this.templatePath('mediatorTemplate/lib/_openhim.js'), this.destinationPath('lib/openhim.js')) | ||
this.fs.copyTpl(this.templatePath('mediatorTemplate/lib/_utils.js'), this.destinationPath('lib/utils.js')) | ||
this.fs.copyTpl(this.templatePath('mediatorTemplate/test/_openhim.js'), this.destinationPath('test/openhim.js')) | ||
this.fs.copyTpl(this.templatePath('mediatorTemplate/test/_test-openhim-server.js'), this.destinationPath('test/test-openhim-server.js')) | ||
|
||
// Add the PPA files | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/_.dput.cf'), this.destinationPath('packaging/.dput.cf'), ppaContext) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/_cp-mediators-into-pkg.sh'), this.destinationPath('packaging/cp-mediators-into-pkg.sh'), ppaContext) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/_create-deb.sh'), this.destinationPath('packaging/create-deb.sh'), ppaContext) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/targets/trusty/debian/_changelog'), this.destinationPath('packaging/targets/trusty/debian/changelog'), ppaContext) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/targets/trusty/debian/_control'), this.destinationPath('packaging/targets/trusty/debian/control'), ppaContext) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/targets/trusty/debian/_postinst'), this.destinationPath('packaging/targets/trusty/debian/postinst'), ppaContext) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/targets/trusty/etc/init/_mediator.conf'), this.destinationPath('packaging/targets/trusty/etc/init/' + ppaContext.appName), ppaContext) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/targets/trusty/debian/_config'), this.destinationPath('packaging/targets/trusty/debian/config')) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/targets/trusty/debian/_install'), this.destinationPath('packaging/targets/trusty/debian/install')) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/targets/trusty/debian/_rules'), this.destinationPath('packaging/targets/trusty/debian/rules')) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/targets/trusty/debian/_templates'), this.destinationPath('packaging/targets/trusty/debian/templates')) | ||
this.fs.copyTpl(this.templatePath('packagingTemplate/targets/trusty/etc/openhim/_install-node-4.sh'), this.destinationPath('packaging/targets/trusty/etc/openhim/install-node-4.sh')) | ||
}, | ||
|
||
install: function () { | ||
this.installDependencies({ | ||
skipInstall: this.options['skip-install'], | ||
npm: true, | ||
bower: false, | ||
callback: function () { | ||
// Have Yeoman greet the user. | ||
// On successful install, have Yeoman greet the user. | ||
console.log(yosay( | ||
'Scaffolding Complete!\r' + | ||
chalk.green('Remember "npm install"\r') + | ||
chalk.green('Simply run: "npm start"\r') + | ||
'Goodbye!' | ||
)); | ||
)) | ||
} | ||
}); | ||
}) | ||
} | ||
}); | ||
}) | ||
|
||
module.exports = mediatorJsGenerator; | ||
module.exports = mediatorJsGenerator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this was here already, but I think let's remove the license field. Tbh I'm not too sure about how licensing works for something like this, but if anything it should be MPL 2.0 (but let's leave it out for now)