Grunt: Removes grunt dependency and replaces some of its usage (#29461)
* Grunt: Removes grunt dependency and replaces some of it usage with alternatives * Removed precommit toolkit task * Fixed toolkit import * Some cleanup of unused / not working stuff in build.go * Removed sass errors
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
module.exports = function(grunt) {
|
||||
'use strict';
|
||||
|
||||
// Concat and Minify the src directory into dist
|
||||
grunt.registerTask('build', ['clean:release', 'clean:build', 'exec:webpack']);
|
||||
};
|
||||
@@ -1,56 +0,0 @@
|
||||
// Lint and build CSS
|
||||
module.exports = function(grunt) {
|
||||
'use strict';
|
||||
|
||||
// prettier-ignore
|
||||
grunt.registerTask('default', [
|
||||
'clean:build',
|
||||
]);
|
||||
|
||||
// prettier-ignore
|
||||
grunt.registerTask('test', [
|
||||
'sasslint',
|
||||
'eslint',
|
||||
'typecheck',
|
||||
'exec:jest',
|
||||
'no-only-tests',
|
||||
'no-focus-convey-tests'
|
||||
]);
|
||||
|
||||
// prettier-ignore
|
||||
grunt.registerTask('eslint', [
|
||||
'newer:exec:eslint'
|
||||
]);
|
||||
|
||||
// prettier-ignore
|
||||
grunt.registerTask('typecheck', [
|
||||
'newer:exec:typecheckPackages',
|
||||
'newer:exec:typecheckRoot'
|
||||
]);
|
||||
|
||||
grunt.registerTask('no-only-tests', function() {
|
||||
var files = grunt.file.expand(
|
||||
'public/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
|
||||
'packages/grafana-data/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
|
||||
'packages/**/*@(_specs|.test).@(ts|js|tsx|jsx)'
|
||||
);
|
||||
grepFiles(files, '.only(', 'found only statement in test: ');
|
||||
});
|
||||
|
||||
grunt.registerTask('no-focus-convey-tests', function() {
|
||||
var files = grunt.file.expand('pkg/**/*_test.go');
|
||||
grepFiles(files, 'FocusConvey(', 'found FocusConvey statement in test: ');
|
||||
});
|
||||
|
||||
function grepFiles(files, pattern, errorMessage) {
|
||||
files.forEach(function(spec) {
|
||||
var rows = grunt.file.read(spec).split('\n');
|
||||
rows.forEach(function(row) {
|
||||
if (row.indexOf(pattern) > 0) {
|
||||
grunt.log.errorlns(row);
|
||||
grunt.fail.warn(errorMessage + spec);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
module.exports = function(config) {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
release: ['<%= destDir %>', '<%= tempDir %>', '<%= genDir %>'],
|
||||
build: ['<%= srcDir %>/build'],
|
||||
temp: ['<%= tempDir %>'],
|
||||
packaging: [],
|
||||
};
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
module.exports = function(config) {
|
||||
'use strict';
|
||||
|
||||
var task = {
|
||||
release: {
|
||||
options: {
|
||||
archive:
|
||||
'<%= destDir %>/<%= pkg.name %><%= enterprise ? "-enterprise" : "" %>-<%= pkg.version %>.<%= platform %>-<%= arch %><%= libc ? "-" + libc : "" %>.tar.gz',
|
||||
},
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
cwd: '<%= tempDir %>',
|
||||
src: ['**/*'],
|
||||
dest: '<%= pkg.name %>-<%= pkg.version %>/',
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
src: ['LICENSE', 'README.md', 'NOTICE.md'],
|
||||
dest: '<%= pkg.name %>-<%= pkg.version %>/',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
if (config.platform === 'windows') {
|
||||
task.release.options.archive =
|
||||
'<%= destDir %>/<%= pkg.name %><%= enterprise ? "-enterprise" : "" %>-<%= pkg.version %>.<%= platform %>-<%= arch %>.zip';
|
||||
}
|
||||
|
||||
return task;
|
||||
};
|
||||
@@ -1,16 +0,0 @@
|
||||
module.exports = function(config, grunt) {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
eslint: {
|
||||
command: 'yarn lint',
|
||||
},
|
||||
typecheckPackages: {
|
||||
command: 'yarn packages:typecheck',
|
||||
},
|
||||
typecheckRoot: {
|
||||
command: 'yarn typecheck',
|
||||
},
|
||||
webpack: 'node ./node_modules/webpack/bin/webpack.js --config scripts/webpack/webpack.prod.js',
|
||||
};
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
module.exports = function(config) {
|
||||
'use strict';
|
||||
return {
|
||||
options: {
|
||||
configFile: 'public/sass/.sass-lint.yml',
|
||||
},
|
||||
src: ['public/sass/**/*.scss', 'packages/**/*.scss', '!**/node_modules/**/*.scss'],
|
||||
};
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
const dev = require('../../webpack/webpack.dev.js');
|
||||
const prod = require('../../webpack/webpack.prod.js');
|
||||
|
||||
module.exports = function() {
|
||||
'use strict';
|
||||
return {
|
||||
options: {
|
||||
stats: false,
|
||||
},
|
||||
dev: dev,
|
||||
prod: prod,
|
||||
};
|
||||
};
|
||||
@@ -1,40 +0,0 @@
|
||||
var path = require('path');
|
||||
|
||||
module.exports = function(grunt) {
|
||||
'use strict';
|
||||
|
||||
// build then zip
|
||||
grunt.registerTask('release', ['build', 'build-post-process']);
|
||||
|
||||
// package into archives
|
||||
grunt.registerTask('package', ['clean:temp', 'build-post-process']);
|
||||
|
||||
grunt.registerTask('build-post-process', function() {
|
||||
grunt.config('copy.public_to_temp', {
|
||||
expand: true,
|
||||
cwd: '<%= srcDir %>',
|
||||
src: '**/*',
|
||||
dest: '<%= tempDir %>/public/',
|
||||
});
|
||||
grunt.config('copy.backend_bin', {
|
||||
cwd: 'bin/<%= platform %>-<%= arch %><%= libc ? "-" + libc : "" %>',
|
||||
expand: true,
|
||||
src: ['*'],
|
||||
options: { mode: true },
|
||||
dest: '<%= tempDir %>/bin/',
|
||||
});
|
||||
grunt.config('copy.backend_files', {
|
||||
expand: true,
|
||||
src: ['conf/**', 'tools/**', 'scripts/*'],
|
||||
options: { mode: true },
|
||||
dest: '<%= tempDir %>',
|
||||
});
|
||||
|
||||
grunt.task.run('copy:public_to_temp');
|
||||
grunt.task.run('copy:backend_bin');
|
||||
grunt.task.run('copy:backend_files');
|
||||
grunt.task.run('clean:packaging');
|
||||
|
||||
grunt.file.write(path.join(grunt.config('tempDir'), 'VERSION'), grunt.config('pkg.version'));
|
||||
});
|
||||
};
|
||||
@@ -1,46 +0,0 @@
|
||||
module.exports = function(grunt) {
|
||||
'use strict';
|
||||
|
||||
function escapeRegExp(str) {
|
||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
||||
}
|
||||
|
||||
function extractColour(line) {
|
||||
var regex = /\s*:\s*(#[a-fA-F0-9]{3,6})\s*(!default|!default;)?/;
|
||||
var matches = line.match(regex);
|
||||
return matches ? matches[1] : matches;
|
||||
}
|
||||
|
||||
function extractVariable(line) {
|
||||
var matches = line.match(/(\$[0-9a-zA-Z_-]+)\s*(!default|!default;)?/);
|
||||
return matches ? matches[1] : matches;
|
||||
}
|
||||
|
||||
function readVars(file, obj) {
|
||||
var content = grunt.file.read(file);
|
||||
var lines = content.split('\n');
|
||||
|
||||
lines.forEach(function(line) {
|
||||
var variable = extractVariable(line);
|
||||
if (variable) {
|
||||
var color = extractColour(line, variable);
|
||||
if (color) {
|
||||
obj[variable] = color;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
grunt.registerTask('styleguide', function() {
|
||||
var data = {
|
||||
dark: {},
|
||||
light: {},
|
||||
};
|
||||
|
||||
readVars('public/sass/_variables.dark.scss', data.dark);
|
||||
readVars('public/sass/_variables.light.scss', data.light);
|
||||
|
||||
var styleGuideJson = grunt.config().srcDir + '/build/styleguide.json';
|
||||
grunt.file.write(styleGuideJson, JSON.stringify(data, null, 4));
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user