init
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
require_once __DIR__ . '/../../app/autoload.php';
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"methodCalls": [
|
||||
{
|
||||
"class": "\\Magento\\Framework\\ObjectManagerInterface",
|
||||
"method": "get",
|
||||
"position": 0
|
||||
},
|
||||
{
|
||||
"class": "\\Magento\\Framework\\ObjectManagerInterface",
|
||||
"method": "create",
|
||||
"position": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var globals = ['Prototype', 'Abstract', 'Try', 'Class', 'PeriodicalExecuter', 'Template', '$break', 'Enumerable', '$A', '$w', '$H', 'Hash', '$R', 'ObjectRange', 'Ajax', '$', 'Form', 'Field', '$F', 'Toggle', 'Insertion', '$continue', 'Position', 'Windows', 'Dialog', 'array', 'WindowUtilities', 'Builder', 'Effect', 'validateCreditCard', 'Validator', 'Validation', 'removeDelimiters', 'parseNumber', 'popWin', 'setLocation', 'setPLocation', 'setLanguageCode', 'decorateGeneric', 'decorateTable', 'decorateList', 'decorateDataList', 'parseSidUrl', 'formatCurrency', 'expandDetails', 'isIE', 'Varien', 'fireEvent', 'modulo', 'byteConvert', 'SessionError', 'varienLoader', 'varienLoaderHandler', 'setLoaderPosition', 'toggleSelectsUnderBlock', 'varienUpdater', 'setElementDisable', 'toggleParentVis', 'toggleFieldsetVis', 'toggleVis', 'imagePreview', 'checkByProductPriceType', 'toggleSeveralValueElements', 'toggleValueElements', 'submitAndReloadArea', 'syncOnchangeValue', 'updateElementAtCursor', 'firebugEnabled', 'disableElement', 'enableElement', 'disableElements', 'enableElements', 'Cookie', 'Fieldset', 'Base64', 'sortNumeric', 'Element', '$$', 'Sizzle', 'Selector', 'Window'];
|
||||
|
||||
globals.forEach(function (prop) {
|
||||
window[prop] = eval(prop);
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var themes = require('../tools/files-router').get('themes'),
|
||||
_ = require('underscore');
|
||||
|
||||
var themeOptions = {};
|
||||
|
||||
_.each(themes, function(theme, name) {
|
||||
themeOptions[name] = {
|
||||
"force": true,
|
||||
"files": [
|
||||
{
|
||||
"force": true,
|
||||
"dot": true,
|
||||
"src": [
|
||||
"<%= path.tmp %>/cache/**/*",
|
||||
"<%= combo.autopath(\""+name+"\", path.pub ) %>**/*",
|
||||
"<%= combo.autopath(\""+name+"\", path.tmpLess) %>**/*",
|
||||
"<%= combo.autopath(\""+name+"\", path.tmpSource) %>**/*",
|
||||
"<%= path.deployedVersion %>"
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
});
|
||||
|
||||
var cleanOptions = {
|
||||
"var": {
|
||||
"force": true,
|
||||
"files": [
|
||||
{
|
||||
"force": true,
|
||||
"dot": true,
|
||||
"src": [
|
||||
"<%= path.tmp %>/cache/**/*",
|
||||
"<%= path.tmp %>/log/**/*",
|
||||
"<%= path.tmp %>/maps/**/*",
|
||||
"<%= path.tmp %>/page_cache/**/*",
|
||||
"<%= path.tmp %>/tmp/**/*",
|
||||
"<%= path.tmp %>/view/**/*",
|
||||
"<%= path.tmp %>/view_preprocessed/**/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"pub": {
|
||||
"force": true,
|
||||
"files": [
|
||||
{
|
||||
"force": true,
|
||||
"dot": true,
|
||||
"src": [
|
||||
"<%= path.pub %>frontend/**/*",
|
||||
"<%= path.pub %>adminhtml/**/*",
|
||||
"<%= path.deployedVersion %>"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"styles": {
|
||||
"force": true,
|
||||
"files": [
|
||||
{
|
||||
"force": true,
|
||||
"dot": true,
|
||||
"src": [
|
||||
"<%= path.tmp %>/view_preprocessed/**/*",
|
||||
"<%= path.tmp %>/cache/**/*",
|
||||
"<%= path.pub %>frontend/**/*.less",
|
||||
"<%= path.pub %>frontend/**/*.css",
|
||||
"<%= path.pub %>adminhtml/**/*.less",
|
||||
"<%= path.pub %>adminhtml/**/*.css",
|
||||
"<%= path.deployedVersion %>"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"markup": {
|
||||
"force": true,
|
||||
"files": [
|
||||
{
|
||||
"force": true,
|
||||
"dot": true,
|
||||
"src": [
|
||||
"<%= path.tmp %>/cache/**/*",
|
||||
"<%= path.tmp %>/view_preprocessed/html/**/*",
|
||||
"<%= path.tmp %>/page_cache/**/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"js": {
|
||||
"force": true,
|
||||
"files": [
|
||||
{
|
||||
"force": true,
|
||||
"dot": true,
|
||||
"src": [
|
||||
"<%= path.pub %>**/*.js",
|
||||
"<%= path.pub %>**/*.html",
|
||||
"<%= path.pub %>_requirejs/**/*",
|
||||
"<%= path.deployedVersion %>"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"generation": {
|
||||
"force": true,
|
||||
"files": [
|
||||
{
|
||||
"force": true,
|
||||
"dot": true,
|
||||
"src": [
|
||||
"<%= path.generation %>code/**/*",
|
||||
"<%= path.generation %>metadata/**/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = _.extend(cleanOptions, themeOptions);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var theme = require('../tools/files-router').get('themes'),
|
||||
path = require('./path');
|
||||
|
||||
/**
|
||||
* Define Combos for repetitive code.
|
||||
*/
|
||||
module.exports = {
|
||||
collector: function (themeName) {
|
||||
var cmdPlus = /^win/.test(process.platform) ? ' & ' : ' && ',
|
||||
command = 'grunt --force clean:' + themeName + cmdPlus;
|
||||
|
||||
command = command + 'php bin/magento dev:source-theme:deploy ' +
|
||||
theme[themeName].files.join(' ') +
|
||||
' --type=less' +
|
||||
' --locale=' + theme[themeName].locale +
|
||||
' --area=' + theme[themeName].area +
|
||||
' --theme=' + theme[themeName].name;
|
||||
|
||||
return command;
|
||||
},
|
||||
|
||||
autopath: function (themeName, folder) {
|
||||
return folder +
|
||||
theme[themeName].area + '/' +
|
||||
theme[themeName].name + '/' +
|
||||
theme[themeName].locale + '/';
|
||||
},
|
||||
|
||||
lessFiles: function (themeName) {
|
||||
var lessStringArray = [],
|
||||
cssStringArray = [],
|
||||
lessFiles = {},
|
||||
i = 0;
|
||||
|
||||
for (i; i < theme[themeName].files.length; i++) {
|
||||
cssStringArray[i] = path.pub +
|
||||
theme[themeName].area + '/' +
|
||||
theme[themeName].name + '/' +
|
||||
theme[themeName].locale + '/' +
|
||||
theme[themeName].files[i] + '.css';
|
||||
|
||||
lessStringArray[i] = path.pub +
|
||||
theme[themeName].area + '/' +
|
||||
theme[themeName].name + '/' +
|
||||
theme[themeName].locale + '/' +
|
||||
theme[themeName].files[i] + '.less';
|
||||
|
||||
lessFiles[cssStringArray[i]] = lessStringArray[i];
|
||||
}
|
||||
|
||||
return lessFiles;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"options": {
|
||||
"stripBanners": true,
|
||||
"banner": "/**\n * Copyright © <%= grunt.template.today(\"yyyy\") %> Magento. All rights reserved.\n * See COPYING.txt for license details.\n */\n"
|
||||
},
|
||||
"setup": {
|
||||
"src": "<%= path.css.setup %>/setup.css",
|
||||
"dest": "<%= path.css.setup %>/setup.css"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"options": {
|
||||
"report": "gzip",
|
||||
"keepSpecialComments": 0
|
||||
},
|
||||
"setup": {
|
||||
"files": {
|
||||
"<%= path.css.setup %>/setup.css": "<%= path.css.setup %>/setup.css"
|
||||
}
|
||||
},
|
||||
"updater": {
|
||||
"files": {
|
||||
"<%= path.css.updater %>/updater.css": "<%= path.css.updater %>/updater.css"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"file": {
|
||||
"options": {
|
||||
"overrideConfigFile": "vendor/magento/magento-coding-standard/eslint/.eslintrc",
|
||||
"rulePaths": ["vendor/magento/magento-coding-standard/eslint/rules"],
|
||||
"useEslintrc": false
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"options": {
|
||||
"overrideConfigFile": "vendor/magento/magento-coding-standard/eslint/.eslintrc",
|
||||
"rulePaths": ["vendor/magento/magento-coding-standard/eslint/rules"],
|
||||
"outputFile": "dev/tests/static/eslint-error-report.xml",
|
||||
"format": "junit",
|
||||
"quiet": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var combo = require('./combo'),
|
||||
themes = require('../tools/files-router').get('themes'),
|
||||
_ = require('underscore');
|
||||
|
||||
var themeOptions = {};
|
||||
|
||||
_.each(themes, function(theme, name) {
|
||||
themeOptions[name] = {
|
||||
cmd: combo.collector.bind(combo, name)
|
||||
};
|
||||
});
|
||||
|
||||
var execOptions = {
|
||||
all : {
|
||||
cmd: function () {
|
||||
var cmdPlus = (/^win/.test(process.platform) == true) ? ' & ' : ' && ',
|
||||
command;
|
||||
|
||||
command = _.map(themes, function(theme, name) {
|
||||
return combo.collector(name);
|
||||
}).join(cmdPlus);
|
||||
|
||||
return 'echo ' + command;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Execution into cmd
|
||||
*/
|
||||
module.exports = _.extend(themeOptions, execOptions);
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var svgo = require('imagemin-svgo');
|
||||
|
||||
/**
|
||||
* Images optimization.
|
||||
*/
|
||||
module.exports = {
|
||||
png: {
|
||||
options: {
|
||||
optimizationLevel: 7
|
||||
},
|
||||
files: [{
|
||||
expand: true,
|
||||
src: ['**/*.png'],
|
||||
ext: '.png'
|
||||
}]
|
||||
},
|
||||
jpg: {
|
||||
options: {
|
||||
progressive: true
|
||||
},
|
||||
files: [{
|
||||
expand: true,
|
||||
src: ['**/*.jpg'],
|
||||
ext: '.jpg'
|
||||
}]
|
||||
},
|
||||
gif: {
|
||||
files: [{
|
||||
expand: true,
|
||||
src: ['**/*.gif'],
|
||||
ext: '.gif'
|
||||
}]
|
||||
},
|
||||
svg: {
|
||||
options: {
|
||||
use: [svgo()]
|
||||
},
|
||||
files: [{
|
||||
expand: true,
|
||||
src: ['**/*.svg'],
|
||||
ext: '.svg'
|
||||
}]
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var combo = require('./combo'),
|
||||
themes = require('../tools/files-router').get('themes'),
|
||||
_ = require('underscore');
|
||||
|
||||
var themeOptions = {};
|
||||
|
||||
_.each(themes, function(theme, name) {
|
||||
themeOptions[name] = {
|
||||
files: combo.lessFiles(name)
|
||||
};
|
||||
});
|
||||
|
||||
var lessOptions = {
|
||||
options: {
|
||||
sourceMap: true,
|
||||
strictImports: false,
|
||||
sourceMapRootpath: '/',
|
||||
sourceMapBasepath: function (f) {
|
||||
this.sourceMapURL = this.sourceMapFilename.substr(this.sourceMapFilename.lastIndexOf('/') + 1);
|
||||
return "/";
|
||||
},
|
||||
dumpLineNumbers: false, // use 'comments' instead false to output line comments for source
|
||||
ieCompat: false
|
||||
},
|
||||
setup: {
|
||||
files: {
|
||||
'<%= path.css.setup %>/setup.css': '<%= path.less.setup %>/_setup.less'
|
||||
}
|
||||
},
|
||||
updater: {
|
||||
files: {
|
||||
'<%= path.css.updater %>/updater.css': '<%= path.less.setup %>/_setup.less'
|
||||
}
|
||||
},
|
||||
documentation: {
|
||||
files: {
|
||||
'<%= path.doc %>/docs.css': '<%= path.doc %>/source/docs.less'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Compiles Less to CSS and generates necessary files if requested.
|
||||
*/
|
||||
module.exports = _.extend(themeOptions, lessOptions);
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"legacy": {
|
||||
"options": {
|
||||
"compressor": "yui-js"
|
||||
},
|
||||
"files": {
|
||||
"<%= path.uglify.legacy %>": [
|
||||
"lib/web/prototype/prototype.js",
|
||||
"lib/web/prototype/window.js",
|
||||
"lib/web/scriptaculous/builder.js",
|
||||
"lib/web/scriptaculous/effects.js",
|
||||
"lib/web/lib/ccard.js",
|
||||
"lib/web/prototype/validation.js",
|
||||
"lib/web/varien/js.js",
|
||||
"lib/web/mage/adminhtml/varienLoader.js",
|
||||
"lib/web/mage/adminhtml/tools.js",
|
||||
"dev/tools/grunt/assets/legacy-build/shim.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Define paths.
|
||||
*/
|
||||
module.exports = {
|
||||
pub: 'pub/static/',
|
||||
tmpLess: 'var/view_preprocessed/less/',
|
||||
tmpSource: 'var/view_preprocessed/source/',
|
||||
tmp: 'var',
|
||||
deployedVersion: 'pub/static/deployed_version.txt',
|
||||
css: {
|
||||
setup: 'setup/pub/styles',
|
||||
updater: '../magento2-updater/pub/css'
|
||||
},
|
||||
less: {
|
||||
setup: 'app/design/adminhtml/Magento/backend/web/app/setup/styles/less',
|
||||
updater: 'app/design/adminhtml/Magento/backend/web/app/updater/styles/less'
|
||||
},
|
||||
uglify: {
|
||||
legacy: 'lib/web/legacy-build.min.js'
|
||||
},
|
||||
doc: 'lib/web/css/docs',
|
||||
spec: 'dev/tests/js/spec',
|
||||
static: {
|
||||
dir: 'dev/tests/static/testsuite/Magento/Test/Js/_files',
|
||||
whitelist: 'dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/',
|
||||
blacklist: 'dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/',
|
||||
tmp: 'validation-files.txt'
|
||||
},
|
||||
generation: 'generated/'
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var nlWin = '\r\n',
|
||||
nlUnix = '\n';
|
||||
|
||||
function findCopyright(lang, nlSys) {
|
||||
var copyrightText = {
|
||||
firstLine: 'Copyright © Magento, Inc. All rights reserved.',
|
||||
secondLine: 'See COPYING.txt for license details.'
|
||||
};
|
||||
switch (lang) {
|
||||
case 'less':
|
||||
return new RegExp(
|
||||
'// /\\*\\*' + nlSys + '// \\* ' +
|
||||
copyrightText.firstLine +
|
||||
'' + nlSys + '// \\* ' +
|
||||
copyrightText.secondLine +
|
||||
'' + nlSys + '// \\*/' + nlSys + nlSys
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
documentation: {
|
||||
options: {
|
||||
patterns: [
|
||||
{
|
||||
match: findCopyright('less', nlWin),
|
||||
replacement: ''
|
||||
},
|
||||
{
|
||||
match: findCopyright('less', nlUnix),
|
||||
replacement: ''
|
||||
}
|
||||
]
|
||||
},
|
||||
files: [{
|
||||
expand: true,
|
||||
flatten: true,
|
||||
src: [
|
||||
'<%= path.doc %>/source/**/*.less'
|
||||
],
|
||||
dest: '<%= path.doc %>/source/'
|
||||
}]
|
||||
}
|
||||
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"documentation": {
|
||||
"options": {
|
||||
"name": "Magento UI Library",
|
||||
"verbose": true,
|
||||
"include": ["<%= path.doc %>/docs.css"]
|
||||
},
|
||||
"files": {
|
||||
"<%= path.doc %>": "<%= path.doc %>/source"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Define Themes
|
||||
*
|
||||
* area: area, one of (frontend|adminhtml|doc),
|
||||
* name: theme name in format Vendor/theme-name,
|
||||
* locale: locale,
|
||||
* files: [
|
||||
* 'css/styles-m',
|
||||
* 'css/styles-l'
|
||||
* ],
|
||||
* dsl: dynamic stylesheet language (less|sass)
|
||||
*
|
||||
*/
|
||||
module.exports = {
|
||||
blank: {
|
||||
area: 'frontend',
|
||||
name: 'Magento/blank',
|
||||
locale: 'en_US',
|
||||
files: [
|
||||
'css/styles-m',
|
||||
'css/styles-l',
|
||||
'css/email',
|
||||
'css/email-inline'
|
||||
],
|
||||
dsl: 'less'
|
||||
},
|
||||
luma: {
|
||||
area: 'frontend',
|
||||
name: 'Magento/luma',
|
||||
locale: 'en_US',
|
||||
files: [
|
||||
'css/styles-m',
|
||||
'css/styles-l'
|
||||
],
|
||||
dsl: 'less'
|
||||
},
|
||||
backend: {
|
||||
area: 'adminhtml',
|
||||
name: 'Magento/backend',
|
||||
locale: 'en_US',
|
||||
files: [
|
||||
'css/styles-old',
|
||||
'css/styles'
|
||||
],
|
||||
dsl: 'less'
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
function printCopyright(lang) {
|
||||
var copyrightText = {
|
||||
firstLine: 'Copyright © Magento, Inc. All rights reserved.',
|
||||
secondLine: 'See COPYING.txt for license details.'
|
||||
},
|
||||
nlWin = '\r\n';
|
||||
switch (lang) {
|
||||
case 'css':
|
||||
return '/**' + nlWin + ' * ' + copyrightText.firstLine + nlWin + ' * ' + copyrightText.secondLine + nlWin + ' */' + nlWin;
|
||||
break;
|
||||
case 'less':
|
||||
return '// /**' + nlWin + '// * ' + copyrightText.firstLine + nlWin + '// * ' + copyrightText.secondLine + nlWin + '// */' + nlWin;
|
||||
break;
|
||||
case 'html':
|
||||
return '<!--' + nlWin + '/**' + nlWin + ' * ' + copyrightText.firstLine + nlWin + ' * ' + copyrightText.secondLine + nlWin + ' */' + nlWin + '-->' + nlWin;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
options: {
|
||||
position: 'top',
|
||||
linebreak: true
|
||||
},
|
||||
setup: {
|
||||
options: {
|
||||
banner: printCopyright('css')
|
||||
},
|
||||
files: {
|
||||
src: '<%= path.css.setup %>/*.css'
|
||||
}
|
||||
},
|
||||
updater: {
|
||||
options: {
|
||||
banner: printCopyright('css')
|
||||
},
|
||||
files: {
|
||||
src: '<%= path.css.updater %>/updater.css'
|
||||
}
|
||||
},
|
||||
documentationCss: {
|
||||
options: {
|
||||
banner: printCopyright('css')
|
||||
},
|
||||
files: {
|
||||
src: '<%= path.doc %>/**/*.css'
|
||||
}
|
||||
},
|
||||
documentationLess: {
|
||||
options: {
|
||||
banner: printCopyright('less')
|
||||
},
|
||||
files: {
|
||||
src: '<%= path.doc %>/**/*.less'
|
||||
}
|
||||
},
|
||||
documentationHtml: {
|
||||
options: {
|
||||
banner: printCopyright('html')
|
||||
},
|
||||
files: {
|
||||
src: '<%= path.doc %>/**/*.html'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var combo = require('./combo'),
|
||||
themes = require('../tools/files-router').get('themes'),
|
||||
_ = require('underscore');
|
||||
|
||||
var themeOptions = {};
|
||||
|
||||
_.each(themes, function (theme, name) {
|
||||
themeOptions[name] = {
|
||||
'files': [
|
||||
'<%= combo.autopath(\''+name+'\', path.pub) %>/**/*.less'
|
||||
],
|
||||
'tasks': 'less:' + name
|
||||
};
|
||||
});
|
||||
|
||||
var watchOptions = {
|
||||
'setup': {
|
||||
'files': '<%= path.less.setup %>/**/*.less',
|
||||
'tasks': 'less:setup'
|
||||
},
|
||||
'updater': {
|
||||
'options': {
|
||||
livereload: true
|
||||
},
|
||||
'files': '<%= path.less.updater %>/**/*.less',
|
||||
'tasks': 'less:updater'
|
||||
},
|
||||
'reload': {
|
||||
'files': '<%= path.pub %>/**/*.css',
|
||||
'options': {
|
||||
livereload: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = _.extend(themeOptions, watchOptions);
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
module.exports = function (grunt) {
|
||||
'use strict';
|
||||
|
||||
var glob = require('glob'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
fst = require('../tools/fs-tools.js'),
|
||||
pc = require('../configs/path');
|
||||
|
||||
grunt.registerTask('black-list-generator', function () {
|
||||
process.chdir(grunt.option('dir') || '.');
|
||||
|
||||
var whiteListFile = glob.sync(pc.static.whitelist + '*.txt')[0],
|
||||
blacklistFile = pc.static.blacklist + path.basename(whiteListFile),
|
||||
whiteList = fst.getData(whiteListFile);
|
||||
|
||||
fst.arrayRead(whiteList, function (data) {
|
||||
fst.write(blacklistFile, data);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
module.exports = function (grunt) {
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs'),
|
||||
_ = require('underscore'),
|
||||
glob = require('glob'),
|
||||
fst = require('../tools/fs-tools'),
|
||||
pc = require('../configs/path'),
|
||||
removeFromFile = function (path, files) {
|
||||
var data = _.difference(fst.getData(path), files);
|
||||
|
||||
fst.write(path, data);
|
||||
};
|
||||
|
||||
grunt.registerTask('clean-black-list', function () {
|
||||
process.chdir(grunt.option('dir') || '.');
|
||||
|
||||
var filesToRemove = grunt.option('file').split(','),
|
||||
files = glob.sync(pc.static.blacklist + '*.txt');
|
||||
|
||||
_.each(files, function (file) {
|
||||
removeFromFile(file, filesToRemove);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
module.exports = function (grunt) {
|
||||
'use strict';
|
||||
|
||||
var exec = require('child_process').execSync,
|
||||
spawn = require('child_process').spawn,
|
||||
log = grunt.log.write,
|
||||
ok = grunt.log.ok,
|
||||
error = grunt.log.error;
|
||||
|
||||
grunt.registerTask('deploy', function () {
|
||||
var deploy,
|
||||
done = this.async();
|
||||
|
||||
log('Cleaning "pub/static"...');
|
||||
exec('rm -rf pub/static/*');
|
||||
ok('"pub/static" is empty.');
|
||||
|
||||
log('Deploying Magento application...');
|
||||
deploy = spawn('php', ['bin/magento', 'setup:static-content:deploy', '-f']);
|
||||
|
||||
deploy.stdout.on('data', function (data) {
|
||||
log(data);
|
||||
});
|
||||
|
||||
deploy.stdin.on('data', function (data) {
|
||||
error(data);
|
||||
});
|
||||
|
||||
deploy.on('close', done);
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
module.exports = function (grunt) {
|
||||
'use strict';
|
||||
|
||||
var compressor = require('node-minify'),
|
||||
_ = require('underscore');
|
||||
|
||||
/**
|
||||
* Helper function used to create config object for compressor.
|
||||
*
|
||||
* @param {Object} options - Options object for a current task.
|
||||
* @param {Object} file - File object with 'sorce' and 'destination' properties.
|
||||
* @return {Object} Config object for compressor.
|
||||
*/
|
||||
function getConfig(options, file) {
|
||||
return _.extend({
|
||||
input: file.src,
|
||||
output: file.dest
|
||||
}, options);
|
||||
}
|
||||
|
||||
grunt.registerMultiTask('mage-minify', 'Minify files with a various compressor engines', function () {
|
||||
var done = this.async(),
|
||||
files = this.files,
|
||||
total = files.length,
|
||||
options = this.options();
|
||||
|
||||
this.files.forEach(function (file, i) {
|
||||
var config = getConfig(options, file);
|
||||
|
||||
/**
|
||||
* Callback function.
|
||||
*/
|
||||
config.callback = function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
done(false);
|
||||
} else if (i === total - 1) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
||||
compressor.minify(config);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
module.exports = function (grunt) {
|
||||
'use strict';
|
||||
|
||||
var pc = require('../configs/path'),
|
||||
fs = require('fs'),
|
||||
cvf = require('../tools/collect-validation-files'),
|
||||
setConfig = function (task, target, data) {
|
||||
var config = grunt.config.get(task);
|
||||
|
||||
config[target].src = data;
|
||||
grunt.config.set(task, config);
|
||||
};
|
||||
|
||||
grunt.registerTask('static', function (target) {
|
||||
var currentTarget = target || 'file',
|
||||
file = grunt.option('file'),
|
||||
tasks = [
|
||||
'continue:on',
|
||||
'eslint:' + currentTarget,
|
||||
'continue:off',
|
||||
'continue:fail-on-warning'
|
||||
];
|
||||
|
||||
setConfig('eslint', currentTarget, cvf.getFiles(file));
|
||||
grunt.task.run(tasks);
|
||||
|
||||
if (!grunt.option('file')) {
|
||||
fs.unlinkSync(pc.static.tmp);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var glob = require('glob'),
|
||||
fs = require('fs'),
|
||||
_ = require('underscore'),
|
||||
fst = require('../tools/fs-tools'),
|
||||
pc = require('../configs/path');
|
||||
|
||||
module.exports = {
|
||||
readFiles: function (paths) {
|
||||
var data = [];
|
||||
|
||||
_.each(paths, function (path) {
|
||||
data = _.union(data, fst.getData(path));
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
getFilesForValidate: function () {
|
||||
var blackListFiles = glob.sync(pc.static.blacklist + '*.txt'),
|
||||
whiteListFiles = glob.sync(pc.static.whitelist + '*.txt'),
|
||||
blackList = this.readFiles(blackListFiles).filter(this.isListEntryValid),
|
||||
whiteList = this.readFiles(whiteListFiles).filter(this.isListEntryValid),
|
||||
files = [],
|
||||
entireBlackList = [];
|
||||
|
||||
fst.arrayRead(blackList, function (data) {
|
||||
entireBlackList = _.union(entireBlackList, data);
|
||||
});
|
||||
|
||||
fst.arrayRead(whiteList, function (data) {
|
||||
files = _.difference(data, entireBlackList);
|
||||
});
|
||||
|
||||
return files;
|
||||
},
|
||||
|
||||
isListEntryValid: function(line) {
|
||||
line = line.trim();
|
||||
return line.length > 0 && line.startsWith('// ') !== true;
|
||||
},
|
||||
|
||||
getFiles: function (file) {
|
||||
var files;
|
||||
|
||||
if (file) {
|
||||
return file.split(',');
|
||||
}
|
||||
|
||||
if (!fs.existsSync(pc.static.tmp)) {
|
||||
fst.write(pc.static.tmp, this.getFilesForValidate());
|
||||
}
|
||||
|
||||
files = fst.getData(pc.static.tmp);
|
||||
if (files.length === 1 && files[0] === '') {
|
||||
files = [];
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var defaultConfig = {},
|
||||
|
||||
/**
|
||||
* Generates full path to file.
|
||||
*
|
||||
* @param {String} path - relative path to file.
|
||||
*
|
||||
* @returns {String} Full path to file
|
||||
*/
|
||||
getFullPath = function (path) {
|
||||
return process.cwd() + '/' + path;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns file.
|
||||
*
|
||||
* @param {String} path - relative path to file.
|
||||
*
|
||||
* @returns {Object|Null} File or NULL
|
||||
*/
|
||||
getFile = function (path) {
|
||||
try {
|
||||
return require(getFullPath(path));
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Immediately invoked function.
|
||||
* Loads user config file.
|
||||
*/
|
||||
userConfig = (function () {
|
||||
try {
|
||||
return require(process.cwd() + '/grunt-config');
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* Loads file.
|
||||
* Load priority:
|
||||
* From user config;
|
||||
* From default config with ".loc" suffix ;
|
||||
* From default config;
|
||||
*
|
||||
* @param {String} alias
|
||||
*
|
||||
* @returns {Object} themes file or error
|
||||
*/
|
||||
get: function (alias) {
|
||||
var tmp;
|
||||
|
||||
if (userConfig && userConfig[alias]) {
|
||||
return require(getFullPath(userConfig[alias]));
|
||||
} else if (tmp = getFile(defaultConfig[alias] + '.loc') || getFile(defaultConfig[alias])) {
|
||||
return tmp;
|
||||
} else {
|
||||
throw new Error('Cannot find file. Alias "' + alias + '" not set. ' +
|
||||
'Use "filesRouter.set" method to set it.').stack;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets file alias.
|
||||
*
|
||||
* @param {String} alias
|
||||
* @param {String} path
|
||||
*/
|
||||
set: function (alias, path) {
|
||||
defaultConfig[alias] = path;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs'),
|
||||
glob = require('glob'),
|
||||
nl = (function () {
|
||||
if (process.platform === 'win32') {
|
||||
return '\r\n';
|
||||
}
|
||||
|
||||
return '\n';
|
||||
})();
|
||||
|
||||
module.exports = {
|
||||
getData: function (filePath) {
|
||||
return this.parseToReadData(fs.readFileSync(filePath));
|
||||
},
|
||||
write: function (file, data) {
|
||||
fs.writeFileSync(file, this.parseToWriteData(data));
|
||||
console.log('The file was saved!');
|
||||
},
|
||||
|
||||
read: function (filePath) {
|
||||
console.log('Collect data from ' + filePath + ': Start!');
|
||||
|
||||
return glob.sync(filePath, {
|
||||
symlinks: true
|
||||
});
|
||||
},
|
||||
|
||||
arrayRead: function (pathArr, callback) {
|
||||
var len = pathArr.length,
|
||||
data = [],
|
||||
i = 0;
|
||||
|
||||
for (; i < len; i++) {
|
||||
data = data.concat(this.read(pathArr[i]));
|
||||
console.log('Collect data from ' + pathArr[i] + ': Finish!');
|
||||
}
|
||||
callback(data);
|
||||
},
|
||||
|
||||
parseToReadData: function (data) {
|
||||
var result = data.toString().split(nl);
|
||||
|
||||
result.pop();
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
parseToWriteData: function (data) {
|
||||
data = data.join(nl) + nl;
|
||||
|
||||
return data;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user