This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -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);
});
});
};
+30
View File
@@ -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);
});
});
};
+35
View File
@@ -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);
});
};
+49
View File
@@ -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);
});
});
};
+36
View File
@@ -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);
}
});
};