Commit b37dba8a authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[FEATURE] make path suggestions dependent on project type

parent 2f1985c9
......@@ -6,42 +6,65 @@ var yeoman = require('yeoman-generator'),
module.exports = yeoman.generators.Base.extend((function() {
var Generator = {},
answers;
answers,
resourcePathsSuggestions = {
extbaseExtension: {
cssPath: path.join('Resources', 'Public', 'StyleSheets'),
sassPath: path.join('Resources', 'Public', 'Sass'),
imagesPath: path.join('Resources', 'Public', 'Images'),
javascriptPath: path.join('Resources', 'Public', 'Scripts')
},
standalone: {
cssPath: 'css',
sassPath: 'sass',
imagesPath: 'images',
javascriptPath: 'javascript'
}
},
projectType = 'standalone';
Generator.initializing = function() {
Generator.pkg = require('../package.json');
};
Generator.prompting = function() {
var done = this.async(),
questions;
var done = this.async();
// Greet the user
this.log(yosay(
'Welcome to the dandy ' + chalk.red('Sgalinski') + ' generator!'
));
this.prompt({
type: 'list',
name: 'projectType',
message: 'What kind of project do you want me to build?',
choices: [
{
value: 'extbaseExtension',
name: 'Typo3 Extbase Extension'
},
{
value: 'standalone',
name: 'Standalone Frontend Project'
},
{
value: 'typo3Frontend',
name: 'Typo3 Frontend Setup'
}
]
}, function(answers) {
projectType = answers.projectType
done();
});
};
Generator.advancedPrompting = function() {
var done = this.async(),
questions;
// define questions
questions = [
{
type: 'list',
name: 'projectType',
message: 'What kind of project do you want me to build?',
choices: [
{
value: 'extbaseExtension',
name: 'Typo3 Extbase Extension'
},
{
value: 'standalone',
name: 'Standalone Frontend Project'
},
{
value: 'typo3Frontend',
name: 'Typo3 Frontend Setup'
}
]
},
{
type: 'input',
name: 'projectName',
......@@ -52,19 +75,19 @@ module.exports = yeoman.generators.Base.extend((function() {
type: 'input',
name: 'cssPath',
message: 'Please specify the path to the compiled css files',
default: 'css'
default: resourcePathsSuggestions[projectType].cssPath
},
{
type: 'input',
name: 'sassPath',
message: 'Please specify the path to the sass source files',
default: 'sass'
default: resourcePathsSuggestions[projectType].sassPath
},
{
type: 'input',
name: 'javascriptPath',
message: 'Please specify the path to the javascript files',
default: 'javascript'
default: resourcePathsSuggestions[projectType].javascriptPath
},
{
type: 'input',
......@@ -76,7 +99,7 @@ module.exports = yeoman.generators.Base.extend((function() {
type: 'input',
name: 'imagesPath',
message: 'Please specify the path to the images',
default: 'images'
default: resourcePathsSuggestions[projectType].imagesPath
}
];
......@@ -99,36 +122,38 @@ module.exports = yeoman.generators.Base.extend((function() {
};
Generator.writeGulp = function() {
this.fs.copyTpl(
this.templatePath('_gulpfile.js'),
this.destinationPath('gulpfile.js'),
answers
);
this.fs.copyTpl(
this.templatePath('gulp/settings.js'),
this.destinationPath('gulp/settings.js'),
answers
);
this.fs.copyTpl(
this.templatePath('gulp/css.js'),
this.destinationPath('gulp/css.js'),
answers
);
this.fs.copyTpl(
this.templatePath('gulp/browser-sync.js'),
this.destinationPath('gulp/browser-sync.js'),
answers
);
this.fs.copyTpl(
this.templatePath('gulp/images.js'),
this.destinationPath('gulp/images.js'),
answers
);
this.fs.copyTpl(
this.templatePath('gulp/javascript.js'),
this.destinationPath('gulp/javascript.js'),
answers
);
if (answers.projectType !== 'extbaseExtension') {
this.fs.copyTpl(
this.templatePath('_gulpfile.js'),
this.destinationPath('gulpfile.js'),
answers
);
this.fs.copyTpl(
this.templatePath('gulp/settings.js'),
this.destinationPath('gulp/settings.js'),
answers
);
this.fs.copyTpl(
this.templatePath('gulp/css.js'),
this.destinationPath('gulp/css.js'),
answers
);
this.fs.copyTpl(
this.templatePath('gulp/browser-sync.js'),
this.destinationPath('gulp/browser-sync.js'),
answers
);
this.fs.copyTpl(
this.templatePath('gulp/images.js'),
this.destinationPath('gulp/images.js'),
answers
);
this.fs.copyTpl(
this.templatePath('gulp/javascript.js'),
this.destinationPath('gulp/javascript.js'),
answers
);
}
};
Generator.writeCompassConfig = function() {
......@@ -167,11 +192,13 @@ module.exports = yeoman.generators.Base.extend((function() {
};
Generator.writeDependencyManagement = function() {
this.fs.copyTpl(
this.templatePath('_package.json'),
this.destinationPath('package.json'),
answers
);
if (answers.projectType !== 'extbaseExtension') {
this.fs.copyTpl(
this.templatePath('_package.json'),
this.destinationPath('package.json'),
answers
);
}
this.fs.copyTpl(
this.templatePath('_bower.json'),
this.destinationPath('bower.json'),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment