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

[FEATURE] implement interaction of extension and typo3 project

parent 6b3f117c
......@@ -2,11 +2,12 @@
var yeoman = require('yeoman-generator'),
chalk = require('chalk'),
yosay = require('yosay'),
path = require('path');
path = require('path'),
_ = require('underscore');
module.exports = yeoman.generators.Base.extend((function() {
var Generator = {},
answers,
answers = {},
resourcePathsSuggestions = {
extbaseExtension: {
cssPath: path.join('Resources', 'Public', 'StyleSheets'),
......@@ -36,78 +37,82 @@ module.exports = yeoman.generators.Base.extend((function() {
'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();
});
},
advancedPrompts: function() {
var done = this.async(),
questions;
// define questions
questions = [
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'
}
]
},
{
type: 'input',
name: 'projectName',
message: 'Please enter the name for your project',
default: process.cwd().split(path.sep).pop()
},
{
type: 'input',
name: 'cssPath',
message: 'Please specify the path to the compiled css files',
default: resourcePathsSuggestions[projectType].cssPath
},
{
type: 'input',
name: 'sassPath',
message: 'Please specify the path to the sass source files',
default: resourcePathsSuggestions[projectType].sassPath
},
{
type: 'input',
name: 'javascriptPath',
message: 'Please specify the path to the javascript files',
default: resourcePathsSuggestions[projectType].javascriptPath
},
{
type: 'input',
name: 'compassConfigPath',
message: 'Please specify the path to config.rb file for compass',
default: '.'
},
{
type: 'input',
name: 'imagesPath',
message: 'Please specify the path to the images',
default: resourcePathsSuggestions[projectType].imagesPath
}
];
// ask questions
this.prompt(questions, function(_answers) {
answers = _answers;
], function(_answers) {
answers = _.extend(answers, _answers);
done();
});
},
pathPrompts: function() {
if (answers.projectType !== 'typo3Frontend') {
var done = this.async(),
questions;
// define questions
questions = [
{
type: 'input',
name: 'cssPath',
message: 'Please specify the path to the compiled css files',
default: resourcePathsSuggestions[answers.projectType].cssPath
},
{
type: 'input',
name: 'sassPath',
message: 'Please specify the path to the sass source files',
default: resourcePathsSuggestions[answers.projectType].sassPath
},
{
type: 'input',
name: 'javascriptPath',
message: 'Please specify the path to the javascript files',
default: resourcePathsSuggestions[answers.projectType].javascriptPath
},
{
type: 'input',
name: 'compassConfigPath',
message: 'Please specify the path to config.rb file for compass',
default: '.'
},
{
type: 'input',
name: 'imagesPath',
message: 'Please specify the path to the images',
default: resourcePathsSuggestions[answers.projectType].imagesPath
}
];
// ask questions
this.prompt(questions, function(_answers) {
answers = _.extend(answers, _answers);
done();
});
}
}
};
......@@ -123,7 +128,7 @@ module.exports = yeoman.generators.Base.extend((function() {
};
Generator.writeGulp = function() {
if (projectType !== 'extbaseExtension') {
if (answers.projectType !== 'extbaseExtension') {
this.fs.copyTpl(
this.templatePath('_gulpfile.js'),
this.destinationPath('gulpfile.js'),
......@@ -158,15 +163,17 @@ module.exports = yeoman.generators.Base.extend((function() {
};
Generator.writeCompassConfig = function() {
this.fs.copyTpl(
this.templatePath('_config.rb'),
this.destinationPath(answers.compassConfigPath + '/config.rb'),
answers
);
if (answers.projectType !== 'typo3Frontend') {
this.fs.copyTpl(
this.templatePath('_config.rb'),
this.destinationPath(answers.compassConfigPath + '/config.rb'),
answers
);
}
};
Generator.writeHtml = function() {
if (projectType === 'standalone') {
if (answers.projectType === 'standalone') {
this.fs.copyTpl(
this.templatePath('_index.html'),
this.destinationPath('index.html'),
......@@ -176,25 +183,41 @@ module.exports = yeoman.generators.Base.extend((function() {
};
Generator.writeSass = function() {
this.fs.copy(
this.templatePath('_main.scss'),
this.destinationPath(answers.sassPath + '/main.scss')
);
if (answers.projectType !== 'typo3Frontend') {
this.fs.copy(
this.templatePath('_main.scss'),
this.destinationPath(answers.sassPath + '/main.scss')
);
}
};
Generator.writeJavascript = function() {
this.fs.copy(
this.templatePath('_main.js'),
this.destinationPath(answers.javascriptPath + '/main.js')
);
if (answers.projectType !== 'typo3Frontend') {
this.fs.copy(
this.templatePath('_main.js'),
this.destinationPath(answers.javascriptPath + '/main.js')
);
}
};
Generator.writeDirectories = function() {
this.mkdir(this.destinationPath(answers.imagesPath));
if (answers.projectType !== 'typo3Frontend') {
this.mkdir(this.destinationPath(answers.imagesPath));
}
};
Generator.writePathConfig = function() {
if (answers.projectType === 'extbaseExtension') {
this.fs.copyTpl(
this.templatePath('_asset-paths.json'),
this.destinationPath('asset-paths.json'),
answers
);
}
};
Generator.writeDependencyManagement = function() {
if (projectType !== 'extbaseExtension') {
if (answers.projectType !== 'extbaseExtension') {
this.fs.copyTpl(
this.templatePath('_package.json'),
this.destinationPath('package.json'),
......
{
"css": "<%= cssPath %>",
"sass": "<%= sassPath %>",
"javascript": "<%= javascriptPath %>",
"compassConfig": "<%= compassConfigPath %>",
"images": "<%= imagesPath %>"
}
'use strict';
var gulp = require('gulp'),
path = require('path'),
argv = require('yargs').argv<% if (projectType == 'typo3Frontend') { %>
extension = (function() {
if (typeof argv.ext === 'undefined') {
throw new Error('You have to specify the extension you want to work on with the --ext option.');
}
return argv.ext;
}())<% } %>;
require('require-dir')('./gulp');
<% if (projectType === 'typo3Frontend') { %>
module.exports = (function() {
'use strict';
var argv = require('yargs').argv,
path = require('path'),
extension = (function() {
if (typeof argv.ext === 'undefined') {
throw new Error('You have to specify the extension you want to work on with the --ext option.');
}
return argv.ext;
}()),
extensionPath = path.join('typo3conf', 'ext', extension),
assetPaths = require('../' + path.join(extensionPath, 'asset-paths.json'));
return {
path: {
css: path.join(extensionPath, assetPaths.css),
sass: path.join(extensionPath, assetPaths.sass),
javascript: path.join(extensionPath, assetPaths.javascript),
compassConfig: path.join(extensionPath, assetPaths.compassConfig),
images: path.join(extensionPath, assetPaths.images)
}
};
})();
<% } else { %>
module.exports = {
path: {
css: '<%= cssPath %>',
......@@ -7,3 +33,4 @@ module.exports = {
images: '<%= imagesPath %>'
}
};
<% } %>
......@@ -23,8 +23,9 @@
"yeoman-generator"
],
"dependencies": {
"yeoman-generator": "^0.18.0",
"chalk": "^0.5.0",
"underscore": "^1.7.0",
"yeoman-generator": "^0.18.0",
"yosay": "^0.3.0"
},
"devDependencies": {
......
Markdown is supported
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