2017-03-30 02:50:05 +09:00
|
|
|
let fs = require('../core/fs.js');
|
|
|
|
let utils = require('../utils/utils.js');
|
2016-08-21 10:42:42 -04:00
|
|
|
|
2017-03-30 20:12:39 +09:00
|
|
|
class TemplateGenerator {
|
2017-06-26 16:48:05 -04:00
|
|
|
constructor(templateName) {
|
2017-03-30 20:12:39 +09:00
|
|
|
this.templateName = templateName;
|
|
|
|
}
|
2016-08-21 10:42:42 -04:00
|
|
|
|
2017-03-30 20:12:39 +09:00
|
|
|
generate(destinationFolder, name) {
|
2018-03-29 19:23:24 -04:00
|
|
|
let templatePath = fs.embarkPath(utils.joinPath('templates', this.templateName));
|
2018-05-08 17:49:46 -04:00
|
|
|
console.log(__('Initializing Embark Template....').green);
|
2017-03-30 20:26:03 +09:00
|
|
|
let fspath = utils.joinPath(destinationFolder, name);
|
2016-08-21 10:42:42 -04:00
|
|
|
|
2017-03-30 20:26:03 +09:00
|
|
|
fs.copySync(templatePath, fspath);
|
|
|
|
utils.cd(fspath);
|
2017-03-30 20:12:39 +09:00
|
|
|
utils.sed('package.json', '%APP_NAME%', name);
|
2017-01-13 19:17:29 -05:00
|
|
|
|
2018-01-03 12:42:38 -05:00
|
|
|
if (name === 'embark_demo') {
|
2018-05-08 17:49:46 -04:00
|
|
|
console.log(__('Installing packages...').green);
|
2018-01-03 12:42:38 -05:00
|
|
|
utils.runCmd('npm install');
|
|
|
|
}
|
|
|
|
|
2018-05-08 17:49:46 -04:00
|
|
|
console.log(__('Init complete').green);
|
|
|
|
console.log('\n' + __('App ready at ').green + fspath);
|
2017-01-13 19:17:29 -05:00
|
|
|
|
2017-03-30 20:12:39 +09:00
|
|
|
if (name === 'embark_demo') {
|
|
|
|
console.log('-------------------'.yellow);
|
2018-05-08 17:49:46 -04:00
|
|
|
console.log(__('Next steps:').green);
|
2017-03-30 20:26:03 +09:00
|
|
|
console.log(('-> ' + ('cd ' + fspath).bold.cyan).green);
|
2017-03-30 20:12:39 +09:00
|
|
|
console.log('-> '.green + 'embark run'.bold.cyan);
|
2018-05-08 17:49:46 -04:00
|
|
|
console.log(__('For more info go to http://embark.status.im').green);
|
2017-03-30 20:12:39 +09:00
|
|
|
}
|
2017-01-13 19:17:29 -05:00
|
|
|
}
|
2017-03-30 20:12:39 +09:00
|
|
|
}
|
2016-08-21 10:42:42 -04:00
|
|
|
|
|
|
|
module.exports = TemplateGenerator;
|