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 {
|
2017-06-26 20:48:05 +00:00
|
|
|
constructor(templateName) {
|
2017-03-30 11:12:39 +00:00
|
|
|
this.templateName = templateName;
|
|
|
|
}
|
2016-08-21 14:42:42 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
generate(destinationFolder, name) {
|
2018-03-29 23:23:24 +00:00
|
|
|
let templatePath = fs.embarkPath(utils.joinPath('templates', this.templateName));
|
2017-03-30 11:12:39 +00:00
|
|
|
console.log('Initializing Embark Template....'.green);
|
2017-03-30 11:26:03 +00:00
|
|
|
let fspath = utils.joinPath(destinationFolder, name);
|
2016-08-21 14:42:42 +00:00
|
|
|
|
2017-03-30 11:26:03 +00:00
|
|
|
fs.copySync(templatePath, fspath);
|
|
|
|
utils.cd(fspath);
|
2017-03-30 11:12:39 +00:00
|
|
|
utils.sed('package.json', '%APP_NAME%', name);
|
2017-01-14 00:17:29 +00:00
|
|
|
|
2018-01-03 17:42:38 +00:00
|
|
|
if (name === 'embark_demo') {
|
|
|
|
console.log('Installing packages...'.green);
|
|
|
|
utils.runCmd('npm install');
|
|
|
|
}
|
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
console.log('Init complete'.green);
|
2017-03-30 11:26:03 +00:00
|
|
|
console.log('\nApp ready at '.green + fspath);
|
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);
|
2017-03-30 11:26:03 +00:00
|
|
|
console.log(('-> ' + ('cd ' + fspath).bold.cyan).green);
|
2017-03-30 11:12:39 +00:00
|
|
|
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;
|