2017-03-29 17:50:05 +00:00
|
|
|
let fs = require('../core/fs.js');
|
|
|
|
let utils = require('../utils/utils.js');
|
2016-08-21 14:42:42 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
class TemplateGenerator {
|
|
|
|
constuctor(templateName) {
|
|
|
|
this.templateName = templateName;
|
|
|
|
}
|
2016-08-21 14:42:42 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
generate(destinationFolder, name) {
|
|
|
|
let templatePath = fs.embarkPath(this.templateName);
|
|
|
|
console.log('Initializing Embark Template....'.green);
|
2016-08-21 14:42:42 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
fs.copySync(templatePath, destinationFolder + name);
|
|
|
|
utils.cd(destinationFolder + name);
|
|
|
|
utils.sed('package.json', '%APP_NAME%', name);
|
2017-01-14 00:17:29 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
console.log('Installing packages.. this can take a few seconds'.green);
|
|
|
|
utils.runCmd('npm install');
|
|
|
|
console.log('Init complete'.green);
|
|
|
|
console.log('\nApp ready at '.green + destinationFolder + name);
|
2017-01-14 00:17:29 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
if (name === 'embark_demo') {
|
|
|
|
console.log('-------------------'.yellow);
|
|
|
|
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);
|
|
|
|
console.log('open another console in the same directory and run'.green);
|
|
|
|
console.log('-> '.green + 'embark run'.bold.cyan);
|
|
|
|
console.log('For more info go to http://github.com/iurimatias/embark-framework'.green);
|
|
|
|
}
|
2017-01-14 00:17:29 +00:00
|
|
|
}
|
2017-03-30 11:12:39 +00:00
|
|
|
}
|
2016-08-21 14:42:42 +00:00
|
|
|
|
|
|
|
module.exports = TemplateGenerator;
|