2017-02-19 12:51:32 -05:00
|
|
|
var fs = require('../core/fs.js');
|
2017-03-11 11:03:20 -05:00
|
|
|
var utils = require('../utils/utils.js');
|
2016-08-21 10:42:42 -04:00
|
|
|
|
|
|
|
var TemplateGenerator = function(templateName) {
|
|
|
|
this.templateName = templateName;
|
|
|
|
};
|
|
|
|
|
|
|
|
TemplateGenerator.prototype.generate = function(destinationFolder, name) {
|
2017-02-19 20:01:42 -05:00
|
|
|
var templatePath = fs.embarkPath(this.templateName);
|
2017-01-13 19:17:29 -05:00
|
|
|
console.log('Initializing Embark Template....'.green);
|
2016-08-21 10:42:42 -04:00
|
|
|
|
2017-02-18 22:40:42 -05:00
|
|
|
fs.copySync(templatePath, destinationFolder + name);
|
2017-02-18 16:06:39 -05:00
|
|
|
utils.cd(destinationFolder + name);
|
2017-02-25 14:34:45 -08:00
|
|
|
utils.sed('package.json', '%APP_NAME%', name);
|
2017-01-13 19:17:29 -05:00
|
|
|
|
|
|
|
console.log('Installing packages.. this can take a few seconds'.green);
|
2017-02-18 16:06:39 -05:00
|
|
|
utils.runCmd('npm install');
|
2017-01-13 19:17:29 -05:00
|
|
|
console.log('Init complete'.green);
|
|
|
|
console.log('\nApp ready at '.green + destinationFolder + name);
|
|
|
|
|
|
|
|
if (name === 'embark_demo') {
|
|
|
|
console.log('-------------------'.yellow);
|
2017-02-19 20:13:30 -05:00
|
|
|
console.log('Next steps:'.green);
|
|
|
|
console.log(('-> ' + ('cd ' + destinationFolder + name).bold.cyan).green);
|
|
|
|
console.log('-> '.green + 'embark blockchain'.bold.cyan + ' or '.green + 'embark simulator'.bold.cyan);
|
2017-01-13 19:17:29 -05:00
|
|
|
console.log('open another console in the same directory and run'.green);
|
2017-02-19 20:13:30 -05:00
|
|
|
console.log('-> '.green + 'embark run'.bold.cyan);
|
2017-01-13 19:17:29 -05:00
|
|
|
console.log('For more info go to http://github.com/iurimatias/embark-framework'.green);
|
|
|
|
}
|
2016-08-21 10:42:42 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = TemplateGenerator;
|