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

[TASK] complete rewrite to match cgl

parent e08bcc3f
...@@ -4,20 +4,25 @@ var yeoman = require('yeoman-generator'), ...@@ -4,20 +4,25 @@ var yeoman = require('yeoman-generator'),
yosay = require('yosay'), yosay = require('yosay'),
path = require('path'); path = require('path');
module.exports = yeoman.generators.Base.extend({ module.exports = yeoman.generators.Base.extend((function() {
initializing: function () { var Generator = {},
this.pkg = require('../package.json'); answers;
},
prompting: function () { Generator.initializing = function() {
var done = this.async(); Generator.pkg = require('../package.json');
};
// Have Yeoman greet the user. Generator.prompting = function() {
var done = this.async(),
questions;
// Greet the user
this.log(yosay( this.log(yosay(
'Welcome to the dandy ' + chalk.red('Sgalinski') + ' generator!' 'Welcome to the dandy ' + chalk.red('Sgalinski') + ' generator!'
)); ));
var prompts = [ // define questions
questions = [
{ {
type: 'list', type: 'list',
name: 'projectType', name: 'projectType',
...@@ -42,55 +47,94 @@ module.exports = yeoman.generators.Base.extend({ ...@@ -42,55 +47,94 @@ module.exports = yeoman.generators.Base.extend({
name: 'projectName', name: 'projectName',
message: 'Please enter the name for your project', message: 'Please enter the name for your project',
default: process.cwd().split(path.sep).pop() default: process.cwd().split(path.sep).pop()
},
{
type: 'input',
name: 'cssPath',
message: 'Please specify the path to the compiled css files',
default: 'css'
},
{
type: 'input',
name: 'sassPath',
message: 'Please specify the path to the sass source files',
default: 'sass'
},
{
type: 'input',
name: 'javascriptPath',
message: 'Please specify the path to the javascript files',
default: 'javascript'
},
{
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: 'images'
} }
]; ];
this.prompt(prompts, function (props) { // ask questions
this.projectType = props.projectType; this.prompt(questions, function(_answers) {
this.projectName = props.projectName; answers = _answers;
done(); done();
}.bind(this)); });
}, };
writing: { Generator.writeGeneralConfigs = function() {
app: function () { this.fs.copy(
this.fs.copyTpl( this.templatePath('_editorconfig'),
this.templatePath('_package.json'), this.destinationPath('.editorconfig')
this.destinationPath('package.json'), );
{projectName: this.projectName} this.fs.copy(
); this.templatePath('_jshintrc'),
this.fs.copy( this.destinationPath('.jshintrc')
this.templatePath('_bower.json'), );
this.destinationPath('bower.json') };
);
},
projectfiles: function () { Generator.writeGulp = function() {
this.fs.copy( this.fs.copyTpl(
this.templatePath('editorconfig'), this.templatePath('_gulpfile.js'),
this.destinationPath('.editorconfig') this.destinationPath('gulpfile.js'),
); answers
this.fs.copy( );
this.templatePath('jshintrc'), this.fs.copyTpl(
this.destinationPath('.jshintrc') this.templatePath('gulp/settings.js'),
); this.destinationPath('gulp/settings.js'),
if (this.projectType === 'standalone') { answers
this.fs.copyTpl( );
this.templatePath('_gulpfile.js'), this.fs.copyTpl(
this.destinationPath('gulpfile.js'), this.templatePath('gulp/css.js'),
{projectType: this.projectType} this.destinationPath('gulp/css.js'),
); answers
this.mkdir('Sass'); );
this.mkdir('Images'); };
this.mkdir('Scripts');
} Generator.writeDependencyManagement = function() {
} this.fs.copyTpl(
}, this.templatePath('_package.json'),
this.destinationPath('package.json'),
answers
);
this.fs.copyTpl(
this.templatePath('_bower.json'),
this.destinationPath('bower.json'),
answers
);
};
install: function () { Generator.install = function() {
this.installDependencies({ this.installDependencies({
skipInstall: this.options['skip-install'] skipInstall: this.options['skip-install']
}); });
} };
});
return Generator;
})());
output_style = :expanded
relative_assets = true
line_comments = false
asset_cache_buster :none
environment = :production
javascripts_dir = '<%= javascriptPath %>'
css_dir = '<%= cssPath %>'
sass_dir = '<%= sassPath %>'
images_dir = '<%= imagesPath %>'
cache_path = '/tmp/sass-cache/';
...@@ -2,40 +2,18 @@ ...@@ -2,40 +2,18 @@
var gulp = require('gulp'), var gulp = require('gulp'),
path = require('path'), path = require('path'),
compass = require('gulp-compass'),
autoprefixer = require('gulp-autoprefixer'),
cssImport = require('gulp-cssimport'),
minifyCss = require('gulp-minify-css'),
browserSync = require('browser-sync'), browserSync = require('browser-sync'),
imagemin = require('gulp-imagemin'), imagemin = require('gulp-imagemin'),
jshint = require('gulp-jshint'), jshint = require('gulp-jshint'),
argv = require('yargs').argv,<% if (projectType == 'typo3Frontend') { %> argv = require('yargs').argv<% if (projectType == 'typo3Frontend') { %>
extension = (function() { extension = (function() {
if (typeof argv.ext === 'undefined') { if (typeof argv.ext === 'undefined') {
throw new Error('You have to specify the extension you want to work on with the --ext option.'); throw new Error('You have to specify the extension you want to work on with the --ext option.');
} }
return argv.ext; return argv.ext;
}()),<% } %> }())<% } %>;
extensionPath = path.join('typo3conf', 'ext', extension),
sassPath = path.join(extensionPath, 'Resources', 'Public', 'Sass'),
cssPath = path.join(extensionPath, 'Resources', 'Public', 'StyleSheets'),
jsPath = path.join(extensionPath, 'Resources', 'Public', 'Scripts'),
imagePath = path.join(extensionPath, 'Resources', 'Public', 'Images');
gulp.task('css', function() { require('require-dir')('./gulp');
return gulp.src(sassPath + '/**/*.scss')
.pipe(compass({
config_file: path.join(extensionPath, 'config.rb'),
sourcemap: true,
css: cssPath,
sass: sassPath
}))
.pipe(cssImport())
.pipe(autoprefixer())
.pipe(minifyCss())
.pipe(gulp.dest(cssPath))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('jshint', function() { gulp.task('jshint', function() {
return gulp.src(jsPath + '/**/*.js') return gulp.src(jsPath + '/**/*.js')
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
"gulp-minify-css": "^0.3.11", "gulp-minify-css": "^0.3.11",
"gulp-imagemin": "^2.1.0", "gulp-imagemin": "^2.1.0",
"gulp-jshint": "^1.9.0", "gulp-jshint": "^1.9.0",
"require-dir": "^0.1.0",
"yargs": "^1.3.3" "yargs": "^1.3.3"
} }
} }
......
'use strict';
var gulp = require('gulp'),
settings = require('./settings'),
compass = require('gulp-compass'),
cssImport = require('gulp-cssimport'),
autoprefixer = require('gulp-autoprefixer'),
minifyCss = require('gulp-minify-css');
// compile sass to css
gulp.task('css', function() {
return gulp.src(settings.path.sass + '/**/*.scss')
.pipe(compass({
config_file: settings.path.compassConfig,
sourcemap: true,
css: settings.path.css,
sass: settings.path.sass
}))
.pipe(cssImport())
.pipe(autoprefixer())
.pipe(minifyCss())
.pipe(gulp.dest(settings.path.css));
});
module.exports = {
path: {
css: '<%= cssPath %>',
sass: '<%= sassPath %>',
javascript: '<%= javascriptPath %>',
compassConfig: '<%= compassConfigPath %>'
}
};
...@@ -20,7 +20,7 @@ describe('sgalinski:app', function () { ...@@ -20,7 +20,7 @@ describe('sgalinski:app', function () {
assert.file([ assert.file([
'bower.json', 'bower.json',
'package.json', 'package.json',
'.editorconfig', '._editorconfig',
'.jshintrc' '.jshintrc'
]); ]);
}); });
......
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