Skip to content

Commit

Permalink
Merge branch 'release/1.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Igloczek committed Dec 18, 2018
2 parents 8bce27e + 5e4a036 commit 752e373
Show file tree
Hide file tree
Showing 10 changed files with 10,464 additions and 1,445 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ rules:
- 'stroustrup'
-
allowSingleLine: false
one-var: 0
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
>=8.9.0 <9.0.0
>=8.9.0 <11.0.0
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ You will find sample config files for theses plugins in `vendor/snowdog/frontool
* `--theme name` - Process single theme.
* `--disableLinting` - Disable SASS and CSS linting.
* `--disableMaps` - Disable inline source maps generation.
* `email-fix` - Fixes email stylesheet for Magento < 2.3.0. [Related issue](https://github.com/MyIntervals/emogrifier/issues/296)
* `--prod` - Production output - minifies styles and add `.min` sufix.
* `eslint` - Watch and run [eslint](https://github.com/adametry/gulp-eslint) on specified JS file.
* `--file fileName` - You have to specify what file you want to lint, fileName without .js.
* `inheritance` - Create necessary symlinks to resolve theme styles inheritance and make the base for styles processing. You have to run in before styles compilation and after adding new files.
Expand Down
24 changes: 13 additions & 11 deletions helper/babel.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
'use strict';
module.exports = function(gulp, plugins, config, name, file) { // eslint-disable-line func-names
const theme = config.themes[name],
srcBase = config.projectPath + 'var/view_preprocessed/frontools' + theme.dest.replace('pub/static', ''),
dest = [],
disableMaps = plugins.util.env.disableMaps || false,
production = plugins.util.env.prod || false,
babelConfig = {
presets: require('babel-preset-env')
};
module.exports = (gulp, plugins, config, name, file) => {
const theme = config.themes[name]
const srcBase = config.projectPath + 'var/view_preprocessed/frontools' + theme.dest.replace('pub/static', '')
const dest = []
const disableMaps = plugins.util.env.disableMaps || false
const production = plugins.util.env.prod || false
const babelConfig = {
presets: [
require('@babel/preset-env')
]
}

function adjustDestinationDirectory(file) {
file.dirname = file.dirname.replace('web/', '');
Expand Down Expand Up @@ -48,11 +50,11 @@ module.exports = function(gulp, plugins, config, name, file) { // eslint-disable
})
)
)
.pipe(plugins.if(!disableMaps && !production, plugins.sourcemaps.init()))
.pipe(plugins.if(!disableMaps, plugins.sourcemaps.init()))
.pipe(plugins.babel(babelConfig))
.pipe(plugins.if(production, plugins.uglify()))
.pipe(plugins.if(!disableMaps && !production, plugins.sourcemaps.write()))
.pipe(plugins.if(production, plugins.rename({ suffix: '.min' })))
.pipe(plugins.if(!disableMaps, plugins.sourcemaps.write('.', { includeContent: true })))
.pipe(plugins.rename(adjustDestinationDirectory))
.pipe(plugins.multiDest(dest))
.pipe(plugins.logger({
Expand Down
27 changes: 12 additions & 15 deletions helper/config-loader.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
'use strict';
module.exports = function(file, plugins, config, failOnError) { // eslint-disable-line func-names
if (typeof failOnError === 'undefined') {
failOnError = true;
}

module.exports = (file, plugins, config, failOnError = true) => {
const externalPath = config.projectPath + 'dev/tools/frontools/config/' + file;

// Check if file exists inside of config directory
// Check if file exists inside the config directory
if (plugins.globby.sync(externalPath).length) {
if (file.includes('yml')) {
return plugins.yaml.safeLoad(plugins.fs.readFileSync(externalPath));
Expand All @@ -15,21 +11,22 @@ module.exports = function(file, plugins, config, failOnError) { // eslint-disabl
return JSON.parse(plugins.fs.readFileSync(externalPath));
}
}
else if (plugins.globby.sync('config/' + file).length) {

if (plugins.globby.sync('config/' + file).length) {
if (file.includes('yml')) {
return plugins.yaml.safeLoad(plugins.fs.readFileSync('config/' + file));
}
else {
return JSON.parse(plugins.fs.readFileSync('config/' + file));
}
}
else {
if (failOnError) {
throw new plugins.util.PluginError({
'plugin' : 'config',
'message': plugins.errorMessage('You have to create ' + file)
})
}
return {};

if (failOnError) {
throw new plugins.util.PluginError({
'plugin' : 'config',
'message': plugins.errorMessage('You have to create ' + file)
})
}

return {}
};
22 changes: 22 additions & 0 deletions helper/email-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'
module.exports = (gulp, plugins, config, name) => {
const production = plugins.util.env.prod || false
const theme = config.themes[name]
const srcBase = config.projectPath + theme.dest
const emailFilename = production ? 'email-inline.min.css' : 'email-inline.css'

return gulp.src(srcBase + '/**/*/' + emailFilename, { base: './' })
.pipe(plugins.if(
!plugins.util.env.ci,
plugins.plumber({
errorHandler: plugins.notify.onError('Error: <%= error.message %>')
})
))
.pipe(plugins.logger({
display : 'rel',
beforeEach: 'Email styles from: ',
afterEach: ' has been fixed!'
}))
.pipe(plugins.replace('@charset "UTF-8";', ''))
.pipe(gulp.dest('./'))
}
Loading

0 comments on commit 752e373

Please sign in to comment.