Skip to content

Commit

Permalink
Merge branch 'release/1.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Igloczek committed Jul 13, 2019
2 parents 7b8fbcc + dd34e84 commit 84ac9ff
Show file tree
Hide file tree
Showing 30 changed files with 7,685 additions and 4,371 deletions.
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ rules:
- 'stroustrup'
-
allowSingleLine: false
one-var: 0
one-var:
- 2
- never
semi:
- 2
- never
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
>=8.9.0 <11.0.0
>=10.13.0 <11.0.0
29 changes: 20 additions & 9 deletions config/browser-sync.json.sample
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
{
"proxy": "m2test.dev",
"rewriteRules": [
{
"match": ".m2test.dev",
"replace": ""
}
]
}
[
{
"proxy": "m2test.dev",
"rewriteRules": [
{
"match": ".m2test.dev",
"replace": ""
}
]
},
{
"proxy": "b2b.m2test.dev",
"rewriteRules": [
{
"match": ".b2b.m2test.dev",
"replace": ""
}
]
}
]
42 changes: 22 additions & 20 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
'use strict';
'use strict'
// Plugins / Functions / Modules
const plugins = require('gulp-load-plugins')({
pattern: ['*', '!gulp', '!gulp-load-plugins'],
rename : {
'browser-sync' : 'browserSync',
'fs-extra' : 'fs',
'gulp-multi-dest' : 'multiDest',
'js-yaml' : 'yaml',
'marked-terminal' : 'markedTerminal',
'merge-stream' : 'mergeStream',
'postcss-reporter': 'reporter',
'run-sequence' : 'runSequence'
}
}),
config = {};
pattern: ['*', '!gulp', '!gulp-load-plugins'],
rename : {
'browser-sync' : 'browserSync',
'fs-extra' : 'fs',
'gulp-multi-dest' : 'multiDest',
'js-yaml' : 'yaml',
'marked-terminal' : 'markedTerminal',
'merge-stream' : 'mergeStream',
'postcss-reporter': 'reporter',
'run-sequence' : 'runSequence'
}
})
const config = {}

config.projectPath = plugins.fs.realpathSync('../../../') + '/';
config.tempPath = config.projectPath + 'var/view_preprocessed/frontools';
config.themes = require('./helper/config-loader')('themes.json', plugins, config, false);
plugins.path = require('path')

plugins.errorMessage = require('./helper/error-message')(plugins);
plugins.getThemes = require('./helper/get-themes')(plugins, config);
config.projectPath = plugins.path.join(plugins.fs.realpathSync('../../../'), '/')
config.tempPath = plugins.path.join(config.projectPath, 'var/view_preprocessed/frontools/')
config.themes = require('./helper/config-loader')('themes.json', plugins, config, false)

plugins.errorMessage = require('./helper/error-message')(plugins)
plugins.getThemes = require('./helper/get-themes')(plugins, config)

// Tasks loading
require('gulp-task-loader')({
dir : 'task',
plugins: plugins,
configs: config
});
})
35 changes: 22 additions & 13 deletions helper/babel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
'use strict'
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 srcBase = plugins.path.join(config.tempPath, theme.dest)
const dest = []
const disableMaps = plugins.util.env.disableMaps || false
const production = plugins.util.env.prod || false
Expand All @@ -12,13 +12,13 @@ module.exports = (gulp, plugins, config, name, file) => {
}

function adjustDestinationDirectory(file) {
file.dirname = file.dirname.replace('web/', '');
return file;
file.dirname = file.dirname.replace('web/', '')
return file
}

theme.locale.forEach(locale => {
dest.push(config.projectPath + theme.dest + '/' + locale);
});
dest.push(plugins.path.join(config.projectPath, theme.dest, locale))
})

// Cleanup existing files from pub to remove symlinks
plugins.globby.sync(file || srcBase + '/**/*.babel.js')
Expand All @@ -28,17 +28,17 @@ module.exports = (gulp, plugins, config, name, file) => {
file
.replace(
srcBase,
config.projectPath + theme.dest + '/' + locale
plugins.path.join(config.projectPath, theme.dest, locale)
)
.replace(
new RegExp('web/([^_]*)$'),
'$1'
)
);
});
});
)
})
})

return gulp.src(
const gulpTask = gulp.src( // eslint-disable-line one-var
file || srcBase + '/**/*.babel.js',
{ base: srcBase }
)
Expand All @@ -62,5 +62,14 @@ module.exports = (gulp, plugins, config, name, file) => {
beforeEach: 'Theme: ' + name + ' ',
afterEach : ' Compiled!'
}))
.pipe(plugins.browserSync.stream());
};

if (plugins.browserSyncInstances) {
Object.keys(plugins.browserSyncInstances).forEach(instanceKey => {
const instance = plugins.browserSyncInstances[instanceKey]

gulpTask.pipe(instance.stream())
})
}

return gulpTask
}
14 changes: 7 additions & 7 deletions helper/config-loader.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
'use strict';
'use strict'
module.exports = (file, plugins, config, failOnError = true) => {
const externalPath = config.projectPath + 'dev/tools/frontools/config/' + file;
const externalPath = plugins.path.join(config.projectPath, 'dev/tools/frontools/config/', file)

// 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));
return plugins.yaml.safeLoad(plugins.fs.readFileSync(externalPath))
}
else {
return JSON.parse(plugins.fs.readFileSync(externalPath));
return JSON.parse(plugins.fs.readFileSync(externalPath))
}
}

if (plugins.globby.sync('config/' + file).length) {
if (file.includes('yml')) {
return plugins.yaml.safeLoad(plugins.fs.readFileSync('config/' + file));
return plugins.yaml.safeLoad(plugins.fs.readFileSync('config/' + file))
}
else {
return JSON.parse(plugins.fs.readFileSync('config/' + file));
return JSON.parse(plugins.fs.readFileSync('config/' + file))
}
}

Expand All @@ -29,4 +29,4 @@ module.exports = (file, plugins, config, failOnError = true) => {
}

return {}
};
}
12 changes: 6 additions & 6 deletions helper/css-lint.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
'use strict'
module.exports = function(gulp, plugins, config, name, file) { // eslint-disable-line func-names
const theme = config.themes[name],
srcBase = config.projectPath + theme.dest,
stylelintConfig = require('../helper/config-loader')('stylelint.yml', plugins, config);
const theme = config.themes[name]
const srcBase = plugins.path.join(config.projectPath, theme.dest)
const stylelintConfig = require('../helper/config-loader')('stylelint.yml', plugins, config)

return gulp.src(file || plugins.globby.sync(srcBase + '/**/*.css'))
.pipe(plugins.if(
Expand All @@ -24,5 +24,5 @@ module.exports = function(gulp, plugins, config, name, file) { // eslint-disable
display : 'name',
beforeEach: 'Theme: ' + name + ' ' + 'File: ',
afterEach : ' - CSS Lint finished.'
}));
};
}))
}
52 changes: 26 additions & 26 deletions helper/dependency-tree-builder.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
'use strict';
'use strict'
module.exports = function(plugins, file) { // eslint-disable-line func-names
function findDependencies(file, dependencyTree) {
if (plugins.fs.existsSync(file)) {
const content = plugins.fs.readFileSync(file, 'utf8'),
path = file.replace(/(.*)\/.*/g, '$1'),
regex = /^(?:\s*@import )(?:'|")(.*)(?:'|")/gm;
const content = plugins.fs.readFileSync(file, 'utf8')
const path = file.replace(/(.*)\/.*/g, '$1')
const regex = /^(?:\s*@import )(?:'|")(.*)(?:'|")/gm

let result = regex.exec(content),
imports = [];
let result = regex.exec(content)
let imports = []

while (result) {
let fullPath = '';
let fullPath = ''
if (result[1].includes('../')) {
let parentPath = path,
filePath = result[1];
let parentPath = path
let filePath = result[1]

while (filePath.includes('../')) {
parentPath = parentPath.replace(/\/[^/]+$/g, '');
filePath = filePath.replace(/\.\.\//, '');
const filePathParts = /(.*)\/(.*)/g.exec(filePath);
parentPath = parentPath.replace(/\/[^/]+$/g, '')
filePath = filePath.replace(/\.\.\//, '')
const filePathParts = /(.*)\/(.*)/g.exec(filePath)
if (filePathParts) {
fullPath = parentPath + '/' + filePathParts[1] + '/_' + filePathParts[filePathParts.length - 1] + '.scss';
fullPath = plugins.path.join(parentPath, filePathParts[1], `_${filePathParts[filePathParts.length - 1]}.scss`)
}
else {
fullPath = parentPath + '/_' + filePath + '.scss';
fullPath = plugins.path.join(parentPath, `_${filePath}.scss`)
}
}
}
else {
if (result[1].includes('/')) {
const filePath = /(.*)\/(.*)/g.exec(result[1]);
fullPath = path + '/' + filePath[1] + '/_' + filePath[filePath.length - 1] + '.scss';
const filePath = /(.*)\/(.*)/g.exec(result[1])
fullPath = plugins.path.join(path, filePath[1], `_${filePath[filePath.length - 1]}.scss`)
}
else {
fullPath = path + '/_' + result[1] + '.scss';
fullPath = plugins.path.join(path, `_${result[1]}.scss`)
}
}
imports.push(fullPath);
result = regex.exec(content);
imports.push(fullPath)
result = regex.exec(content)
}

imports.forEach(el => {
imports = imports.concat(findDependencies(el, dependencyTree));
});
imports = imports.concat(findDependencies(el, dependencyTree))
})

dependencyTree = dependencyTree.concat(file);
dependencyTree = dependencyTree.concat(imports);
dependencyTree = dependencyTree.concat(file)
dependencyTree = dependencyTree.concat(imports)
}
return dependencyTree;
return dependencyTree
}

return findDependencies(file, []);
};
return findDependencies(file, [])
}
2 changes: 1 addition & 1 deletion helper/email-fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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 srcBase = plugins.path.join(config.projectPath, theme.dest)
const emailFilename = production ? 'email-inline.min.css' : 'email-inline.css'

return gulp.src(srcBase + '/**/*/' + emailFilename, { base: './' })
Expand Down
6 changes: 3 additions & 3 deletions helper/error-message.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
'use strict'
module.exports = function(plugins) { // eslint-disable-line func-names
return function(message) { // eslint-disable-line func-names
const lineLength = message.length > 50 ? 50 : message.length;
const lineLength = message.length > 50 ? 50 : message.length
return plugins.util.colors.red('\n' + '='.repeat(lineLength) + ' \n')
+ plugins.util.colors.yellow(message)
+ plugins.util.colors.red('\n' + '='.repeat(lineLength))
}
};
}
12 changes: 6 additions & 6 deletions helper/get-themes.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
'use strict'
module.exports = function(plugins, config) { // eslint-disable-line func-names
return function() { // eslint-disable-line func-names
const themeName = plugins.util.env.theme || false,
themes = Object.keys(config.themes);
const themeName = plugins.util.env.theme || false
const themes = Object.keys(config.themes)

// If themes is empty we throw a configuration error
if (themes.length === 0) {
Expand All @@ -16,9 +16,9 @@ module.exports = function(plugins, config) { // eslint-disable-line func-names
throw new plugins.util.PluginError({
plugin : 'config',
message: plugins.errorMessage(themeName + ' theme is not defined in themes.json')
});
})
}

return themeName ? [themeName] : themes;
return themeName ? [themeName] : themes
}
};
}
Loading

0 comments on commit 84ac9ff

Please sign in to comment.