UNPKG

generator-thundr-gae-angular1

Version:

Yeoman generator for an Angular 1.x app that runs atop Thundr on Google App Engine

99 lines (85 loc) 2.57 kB
'use strict'; const Generator = require('yeoman-generator'); const chalk = require('chalk'); const yosay = require('yosay'); const mkdirp = require('mkdirp'); const slugify = value => require('slugify')(value).toLowerCase(); const _ = require('lodash'); module.exports = class extends Generator { prompting() { // Have Yeoman greet the user. this.log(yosay( 'Welcome to the brilliant ' + chalk.red('thundr-gae-angular1') + ' generator!' )); const prompts = [ { name: 'project', message: 'What is the ID of this project?', store: true, default: slugify(this.appname) }, { name: 'projectName', message: 'What is the name of this project?', store: true, default: _.startCase(this.appname) }, { name: 'gitPath', message: 'What is the HTTPS git path for this project (without username prefix)?', store: true }, { name: 'adminEmail', message: 'What email address should we use to create the initial admin login?', store: true } ]; return this.prompt(prompts).then(props => { // To access props later use this.props.someAnswer; this.props = props; }); } writing() { const context = Object.assign({}, this.props, { project: slugify(this.props.project), slugify, _ }); const copyTpl = (src, dest) => { const destName = dest || src; const srcParam = !_.isArray(src) ? this.templatePath(src) : _.map(src, entry => _.startsWith(entry, '!') ? entry : this.templatePath(entry)); return this.fs.copyTpl(srcParam, this.destinationPath(destName), context); }; const copy = (src, dest) => { const destName = dest || src; return this.fs.copy(this.templatePath(src), this.destinationPath(destName)); }; copyTpl('package.json'); copyTpl('pom.xml'); copyTpl('README.md'); copyTpl('webpack.config.js'); copyTpl('karma.conf.js'); copyTpl('clean.js'); copyTpl('tsconfig.json'); copyTpl('tslint.json'); copyTpl('gitignore', '.gitignore'); copyTpl('java-version', '.java-version'); copyTpl('editorconfig', '.editorconfig'); copy('src'); copy('etc'); copyTpl('src/main/resources'); copyTpl('src/main/client/app/admin/navbar'); mkdirp('src/main/client/fonts'); mkdirp('src/main/client/images'); } install() { this.installDependencies({ npm: true, bower: false, yarn: false }); } };