all files / js/ routeGenerator.js

88.24% Statements 15/17
100% Branches 0/0
50% Functions 2/4
88.24% Lines 15/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                                                 
'use strict';
 
let fse = require('fs-extra');
let path = require('path');
let moduleTplt = require('./templates/component/module').moduleTemplate;
let routeTplt = require('./templates/component/route').routeTemplate;
let componentTplt = require('./templates/component/component').componentTemplate;
let controllerTplt = require('./templates/component/controller').controllerTemplate;
 
class RouteGenerator {
 
  constructor(routeName) {
    this.routeName = routeName;
 
    this.filePath = path.join('src', 'ts', 'app', 'routes', this.routeName);
 
    fse.mkdirsSync(this.filePath);
  }
 
  buildRoute() {
    this._createNewFiles();
 
    this._updateOrCreateRouteConfig();
  }
 
  _createNewFiles() {
 
    fse.writeFileSync(path.join(this.filePath, `${this.routeName}.component.ts`), componentTplt(this.routeName));
    fse.writeFileSync(path.join(this.filePath, `${this.routeName}.controller.ts`), controllerTplt(this.routeName));
    fse.writeFileSync(path.join(this.filePath, `${this.routeName}.module.ts`), moduleTplt(this.routeName));
    fse.writeFileSync(path.join(this.filePath, `${this.routeName}.route.ts`), routeTplt(this.routeName));
    fse.writeFileSync(path.join(this.filePath, `${this.routeName}.template.html`), '');
  }
 
  _updateOrCreateRouteConfig() {
 
  }
}
 
module.exports = RouteGenerator;