Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #210 from gskema/dev
Browse files Browse the repository at this point in the history
[*] JS: Follow up bourbon workflow #209
  • Loading branch information
Gytis Šk committed May 15, 2016
2 parents 7b52451 + 0db4a53 commit b1ee4fc
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 119 deletions.
176 changes: 89 additions & 87 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,106 +2,108 @@ var gulp = require('gulp');
var del = require('del');
var mkdirp = require('mkdirp');
var glob = require('glob-all');
var exec = require('child_process').exec;
var argv = require('yargs').argv;
var fs = require('fs-extra');
var zip = require('gulp-zip');
var runSequence = require('run-sequence');
var jscs = require('gulp-jscs');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var notify = require("gulp-notify");
var bourbon = require('node-bourbon');

var themeName = 'community-theme-16';

var createFolders = [
'./themes/' + themeName + '/cache/',
'./themes/' + themeName + '/pdf/',
'./themes/' + themeName + '/pdf/lang/'
'./themes/' + themeName + '/cache/',
'./themes/' + themeName + '/pdf/',
'./themes/' + themeName + '/pdf/lang/'
];

var copyIndexIgnore = [];

var cleanUp = [
'./themes/' + themeName + '/.sass-cache/',
'./themes/' + themeName + '/cache/*',
'./themes/' + themeName + '/css/**/*.css.map'
'./themes/' + themeName + '/.sass-cache/',
'./themes/' + themeName + '/cache/*',
'./themes/' + themeName + '/css/**/*.css.map'
];

gulp.task('create-folders', function(callback){
var total = createFolders.length;
var done = 0;

if (total < 1 && callback) {
var total = createFolders.length;
var done = 0;

if (total < 1 && callback) {
callback();
}

createFolders.forEach(function(path){
mkdirp(path, function (err) {
if (err) {
console.error(err);
} else {
console.log('Created folder : ' + path);
}

done++;
if (done == total && callback) {
callback();
}

createFolders.forEach(function(path){
mkdirp(path, function (err) {
if (err) {
console.error(err);
} else {
console.log('Created folder : ' + path);
}

done++;
if (done == total && callback) {
callback();
}
});
}
});
});
});

function displayNotification(msg){
return notify(msg);
return notify(msg);
}

gulp.task('compile-css', function(callback){
return gulp.src('./themes/' + themeName + '/sass/**/*.scss')
.pipe(sass({includePaths: require('node-bourbon').includePaths})
.on('error', function()
{
displayNotification(sass.logError);
}))
.pipe(sourcemaps.init())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./themes/' + themeName + '/css/'))
.pipe(displayNotification({ message: 'Compilation successful', onLast: true }));
gulp.task('compile-css', function(){
return gulp.src('./themes/' + themeName + '/sass/**/*.scss')
.pipe(sass({
includePaths: bourbon.includePaths,
outputStyle: 'expanded',
precision: 8
})
.on('error', function() {
displayNotification(sass.logError);
}))
.pipe(sourcemaps.init())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./themes/' + themeName + '/css/'))
.pipe(displayNotification({ message: 'Compilation successful', onLast: true }));
});

gulp.task('sass:watch', function () {
gulp.watch('./themes/' + themeName + '/sass/**/*.scss', ['compile-css']);
});

gulp.task('clean-up', function(){
return del(cleanUp).then(function() {
console.log('Deleted files and folders:\n', cleanUp.join('\n'));
});
return del(cleanUp).then(function() {
console.log('Deleted files and folders:\n', cleanUp.join('\n'));
});
});

gulp.task('copy-index', function(callback){
var total;
var done = 0;
glob(['themes/' + themeName + '/**/', 'modules/*/**/'], { ignore : copyIndexIgnore }, function(err, folders) {
total = folders.length;
if (total < 1 && callback) {
callback();
var total;
var done = 0;
glob(['themes/' + themeName + '/**/', 'modules/*/**/'], { ignore : copyIndexIgnore }, function(err, folders) {
total = folders.length;
if (total < 1 && callback) {
callback();
}

// console.log('Copy to folders: \n', folders.join('\n'));
folders.forEach(function(folder) {
fs.copy('index.php.copy', folder + '/index.php', function(err) {
if (err) {
return console.error(err);
}

// console.log('Copy to folders: \n', folders.join('\n'));
folders.forEach(function(folder) {
fs.copy('index.php.copy', folder + '/index.php', function(err) {
if (err) {
return console.error(err);
}

done++;
if (done == total && callback) {
callback();
}
});
});
done++;
if (done == total && callback) {
callback();
}
});
});
});
});

gulp.task('format-js', function () {
Expand All @@ -117,38 +119,38 @@ gulp.task('format-js', function () {
});

gulp.task('create-zip', function(){
fs.readFile('./Config.xml', 'utf8', function (err, data) {
if (err) {
return console.error(err);
}
fs.readFile('./Config.xml', 'utf8', function (err, data) {
if (err) {
return console.error(err);
}

var themeVersion = '';
var pattern = new RegExp(/<theme\s[^>]*?version=\"(.*?)\"/i);
var matches = data.match(pattern);
var themeVersion = '';
var pattern = new RegExp(/<theme\s[^>]*?version=\"(.*?)\"/i);
var matches = data.match(pattern);

if (matches !== null && typeof matches[1] == 'string') {
themeVersion = matches[1].trim();
}
if (matches !== null && typeof matches[1] == 'string') {
themeVersion = matches[1].trim();
}

return gulp.src([
'./themes*/' + themeName + '*/**',
'./modules*/ct*/**',
'./Config.xml'
])
.pipe(zip('v' + themeVersion + '-' + themeName + '.zip'))
.pipe(gulp.dest('./'));
});
return gulp.src([
'./themes*/' + themeName + '*/**',
'./modules*/ct*/**',
'./Config.xml'
])
.pipe(zip('v' + themeVersion + '-' + themeName + '.zip'))
.pipe(gulp.dest('./'));
});
});

gulp.task('build', function(callback) {
runSequence(
['create-folders', 'compile-css'],
'clean-up',
'format-js',
'copy-index',
'create-zip',
callback
);
runSequence(
['create-folders', 'compile-css'],
'clean-up',
'format-js',
'copy-index',
'create-zip',
callback
);
});

gulp.task('default', ['build']);
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"node-bourbon": "^4.2.8",
"mkdirp": "^0.5.1",
"run-sequence": "^1.1.5",
"yargs": "^4.2.0",
"gulp-notify": "^2.2.0"
}
}
31 changes: 0 additions & 31 deletions themes/community-theme-16/config.rb

This file was deleted.

0 comments on commit b1ee4fc

Please sign in to comment.