generator-levi-9-angularjs-2
Version:
Yeoman generator for levi9 angularjs2 projects
155 lines (137 loc) • 4.41 kB
JavaScript
'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
module.exports = yeoman.Base.extend({
prompting: function () {
this.log(yosay(
'Welcome to the fabulous ' + chalk.green('Levi9 angularjs 2') + ' generator!'
));
var prompts = [
{
type: 'input',
name: 'appName',
message: 'What is the name of your app?',
default: this.appname
},
{
type: 'input',
name: 'appDesc',
message: 'Describe your app',
default: ''
},
{
type: 'input',
name: 'appVersion',
message: 'What is start version of your app?',
default: '1.0.0'
},
{
type: 'input',
name: 'appAuthor',
message: 'Author:',
default: this.user.git.email()
},
{
type: 'input',
name: 'keywords',
message: 'Keywords (comma separated):'
},
{
type: 'input',
name: 'repoUrl',
message: 'Repository url:'
},
{
type: 'input',
name: 'bugsUrl',
message: 'Bugs tracker url:'
},
{
type: 'list',
name: 'license',
message: 'Choose license type:',
choices: ['Levi9, all rights reserved', 'MIT', 'GPL']
},
{
type: 'confirm',
name: 'useSass',
message: 'Would you like to use sass?',
default: false
}
];
return this.prompt(prompts).then(function (props) {
this.props = props;
this.config.set('useSass', props.useSass);
this.config.save();
}.bind(this));
},
writing: function () {
this.style = this.props.useSass ? 'scss' : 'css';
this.styleIgnore = this.props.useSass ? 'css' : 'scss';
this.fs.copy(
this.templatePath('levi9-angular2-webpack-seed'),
this.destinationPath(''),
{globOptions: {ignore: ['**/**.' + this.styleIgnore, '**/**/**.' + this.styleIgnore]}}
);
this.fs.copy(
this.templatePath('levi9-angular2-webpack-seed/.*'),
this.destinationPath('')
);
this.fs.copyTpl(
this.templatePath('levi9-angular2-webpack-seed/package.json'),
this.destinationPath('package.json'),
{
name: this.props.appName,
desc: this.props.appDesc,
version: this.props.appVersion,
author: this.props.appAuthor,
keywords: this.props.keywords,
repoUrl: this.props.repoUrl,
bugsUrl: this.props.bugsUrl,
license: this.props.license
}
);
this.fs.copyTpl(
this.templatePath('levi9-angular2-webpack-seed/config/webpack.common.js'),
this.destinationPath('config/webpack.common.js'), {name: this.props.appName}
);
this.fs.copyTpl(
this.templatePath('levi9-angular2-webpack-seed/README.md'),
this.destinationPath('README.md'),
{
name: this.props.appName,
desc: this.props.appDesc
}
);
this.fs.copyTpl(
this.templatePath('levi9-angular2-webpack-seed/LICENSE'),
this.destinationPath('LICENSE'), {license: this.props.license}
);
this.fs.copyTpl(
this.templatePath('levi9-angular2-webpack-seed/src/app/app.component.ts'),
this.destinationPath('src/app/app.component.ts'), {style: this.style}
);
this.fs.copyTpl(
this.templatePath('levi9-angular2-webpack-seed/src/app/main/main.component.ts'),
this.destinationPath('src/app/main/main.component.ts'), {style: this.style}
);
this.fs.copyTpl(
this.templatePath('levi9-angular2-webpack-seed/src/app/header/header.component.ts'),
this.destinationPath('src/app/header/header.component.ts'), {style: this.style}
);
this.fs.copyTpl(
this.templatePath('levi9-angular2-webpack-seed/src/app/footer/footer.component.ts'),
this.destinationPath('src/app/footer/footer.component.ts'), {style: this.style}
);
this.fs.copyTpl(
this.templatePath('levi9-angular2-webpack-seed/src/app/no-content/no-content.ts'),
this.destinationPath('src/app/no-content/no-content.ts'), {style: this.style}
);
},
install: function () {
this.installDependencies({
bower: false
});
}
});