Skip to content

Commit

Permalink
Merged release/0.7.0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Igloczek committed Apr 13, 2016
2 parents 3806e3e + 9413dee commit 4978a13
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 50 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "snowdog/frontools",
"description": "Set of front-end tools for Magento 2, based on Gulp.js",
"version": "0.6.1",
"version": "0.7.0",
"license": "MIT",
"type": "magento2-component",
"extra": {
Expand Down
File renamed without changes.
39 changes: 28 additions & 11 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')({
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')({
pattern: ['*', '!gulp', '!gulp-load-plugins'],
rename: {
'browser-sync': 'browserSync',
'run-sequence': 'runSequence'
'browser-sync' : 'browserSync',
'marked-terminal': 'markedTerminal',
'run-sequence' : 'runSequence'
}
});
plugins.browserSync.create();

// Check if user create themes configuration
if (!plugins.globby.sync('./configs/themes.json').length) {
plugins.util.log(
plugins.util.colors.red('\n========================================= \n')
+ plugins.util.colors.yellow('You have to create ')
+ plugins.util.colors.blue('configs/themes.json')
+ plugins.util.colors.red('\n=========================================')
);
throw new plugins.util.PluginError({
plugin: 'configs',
message: 'You have to create configs/themes.json'
});
}

var configs = {
'browserSync': require('./configs/browser-sync.json'),
'csslint' : require('./configs/css-lint.json'),
'eslint' : require('./configs/eslint.json'),
'themes' : require('./configs/themes.json')
};
var tasks = require('gulp-task-loader')({
'browserSync': require('./configs/browser-sync.json'),
'csslint' : require('./configs/css-lint.json'),
'eslint' : require('./configs/eslint.json'),
'themes' : require('./configs/themes.json')
},
tasks = require('gulp-task-loader')({
dir : 'tasks',
plugins: plugins,
configs: configs
});

plugins.browserSync.create();

// define task for each theme, locale, lang, processing type etc.
// gulp can't run same task in parallel, so we need different names
Object.keys(configs.themes).forEach(name => {
Expand Down
6 changes: 4 additions & 2 deletions helpers/css-lint-custom-reporter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = function(gulp, plugins, configs) {
function customReporter(file) {
plugins.util.log(plugins.util.colors.cyan(file.csslint.errorCount)
+ ' errors in ' + plugins.util.colors.magenta(file.path));
plugins.util.log(
plugins.util.colors.cyan(file.csslint.errorCount)
+ ' errors in ' + plugins.util.colors.magenta(file.path)
);

file.csslint.results.forEach(function(result) {
if (result.error.type === 'warning') {
Expand Down
12 changes: 3 additions & 9 deletions helpers/dependency-tree-builder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module.exports = function(theme, file) {
var globby = require('globby'),
fs = require('fs');

const fs = require('fs');

function findDependencies(file, dependencyTree) {
var content = fs.readFileSync(file, 'utf8'),
path = file.replace(/(.*)\/.*/g, '$1'),
Expand Down Expand Up @@ -36,10 +35,5 @@ module.exports = function(theme, file) {
return dependencyTree;
}

if (theme.lang === 'less') {
return findDependencies(file, []);
}
else {
return [theme.src + '/**/*.' + theme.lang];
}
return findDependencies(file, []);
};
9 changes: 6 additions & 3 deletions helpers/less.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ module.exports = function(gulp, plugins, configs, name, locale, file) {
// less compiler is dumb as f*ck
// can't figure out what files to process when path is like "theme/**/*.less"
if (!lessFiles.length) {
var globby = require('globby'),
files = globby.sync([src + '/**/*.less', '!' + src + '/**/_*.less']);

var files = plugins.globby.sync([
src + '/**/*.less',
'!' + src + '/**/_*.less',
'!/**/node_modules/**'
]);

files.forEach(file => lessFiles.push(file));
}

Expand Down
2 changes: 1 addition & 1 deletion helpers/scss.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = function(gulp, plugins, configs, name, locale, file) {
production = plugins.util.env.prod || false,
postcss = theme.postcss || false;

return gulp.src(src, {base: theme.src + '/web'})
return gulp.src([src, '!/**/node_modules/**'], {base: theme.src + '/web'})
.pipe(plugins.plumber({ errorHandler: plugins.notify.onError("Error: <%= error.message %>") }))
.pipe(plugins.if(maps, plugins.sourcemaps.init()))
.pipe(plugins.sass())
Expand Down
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,33 @@
"name": "Bartek Igielski",
"email": "[email protected]"
},
"verions": "0.6.0",
"repository": {
"type": "git",
"url": "https://github.com/SnowdogApps/magento2-frontools"
},
"license": "MIT",
"engine": "node >= 4.2.6",
"engines": "node >= 4.2.6",
"devDependencies": {
"autoprefixer": "6.3.1",
"browser-sync": "2.11.1",
"cssnano": "3.4.0",
"autoprefixer": "6.3.6",
"browser-sync": "2.12.2",
"cssnano": "3.5.2",
"globby": "4.0.0",
"gulp": "3.9.0",
"gulp": "3.9.1",
"gulp-concat": "2.6.0",
"gulp-csslint": "0.2.0",
"gulp-csslint": "0.3.0",
"gulp-eslint": "1.1.1",
"gulp-if": "2.0.0",
"gulp-less": "3.0.5",
"gulp-load-plugins": "1.2.0",
"gulp-logger": "0.0.2",
"gulp-notify": "2.2.0",
"gulp-plumber": "1.0.1",
"gulp-postcss": "6.0.1",
"gulp-plumber": "1.1.0",
"gulp-postcss": "6.1.0",
"gulp-rimraf": "0.2.0",
"gulp-sass": "2.1.1",
"gulp-sass": "2.2.0",
"gulp-sourcemaps": "1.6.0",
"gulp-task-loader": "1.3.1",
"gulp-uglify": "1.5.1",
"gulp-task-loader": "1.4.2",
"gulp-uglify": "1.5.3",
"gulp-util": "3.0.7",
"marked": "0.3.5",
"marked-terminal": "1.6.1",
Expand Down
10 changes: 4 additions & 6 deletions tasks/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ module.exports = function() {
configs = this.opts.configs;

// local plugins and configs
var marked = require('marked'),
renderer = require('marked-terminal')
fs = require('fs');
const fs = require('fs');

marked.setOptions({
renderer: new renderer()
plugins.marked.setOptions({
renderer: new plugins.markedTerminal()
});

console.log(marked(fs.readFileSync('./readme.md', 'UTF-8')));
console.log(plugins.marked(fs.readFileSync('./readme.md', 'UTF-8')));
}
2 changes: 1 addition & 1 deletion tasks/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function() {
configs = this.opts.configs;

// local plugins and configs
var execSync = require('child_process').execSync;
const execSync = require('child_process').execSync;

// local vars
var themeName = plugins.util.env.theme || false,
Expand Down
7 changes: 3 additions & 4 deletions tasks/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ module.exports = function() {
configs = this.opts.configs;

// local vars
var globby = require('globby');
themeName = plugins.util.env.theme || false,
var themeName = plugins.util.env.theme || false,
themes = themeName ? [themeName] : Object.keys(configs.themes);

themes.forEach(name => {
var theme = configs.themes[name];
theme.locale.forEach(locale => {
var themePath = theme.default ? theme.dest + '/' + locale : theme.src,
files = globby.sync(
files = plugins.globby.sync(
[
themePath + '/**/*.' + theme.lang,
'!' + themePath + '/**/_*.' + theme.lang
Expand All @@ -31,7 +30,7 @@ module.exports = function() {
}
else {
var compiler = require('../helpers/' + theme.lang)(gulp, plugins, configs, name, locale, themePath + '/**/*.' + theme.lang);
gulp.watch(themePath + '/**/*.' + theme.lang, () => {
gulp.watch([themePath + '/**/*.' + theme.lang, '!/**/node_modules/**'], () => {
compiler();
});
}
Expand Down

0 comments on commit 4978a13

Please sign in to comment.