mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
remove todos.md
This commit is contained in:
parent
3077ace5b4
commit
ebf07f39b6
3 changed files with 1 additions and 574 deletions
467
TODOS.md
467
TODOS.md
File diff suppressed because one or more lines are too long
|
@ -44,7 +44,7 @@
|
|||
"scripts": {
|
||||
"test": "grunt test --use-jruby",
|
||||
"server": "grunt server",
|
||||
"precommit": "grunt jshint todos render_readme"
|
||||
"precommit": "grunt jshint render_readme"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
106
tasks/todos.js
106
tasks/todos.js
|
@ -1,106 +0,0 @@
|
|||
module.exports = function (grunt) {
|
||||
var _ = require('lodash');
|
||||
var Promise = require('bluebird');
|
||||
var readFileAsync = Promise.promisify(require('fs').readFile);
|
||||
var spawnAsync = Promise.promisify(grunt.util.spawn);
|
||||
var path = require('path');
|
||||
var absolute = _.partial(path.join, path.join(__dirname, '..'));
|
||||
|
||||
var TODO_RE = /[\s\/\*]+(TODO|FIXME):?\s*(.+)/;
|
||||
var NEWLINE_RE = /\r?\n/;
|
||||
var TODO_FILENAME = 'TODOS.md';
|
||||
var TYPE_PRIORITIES = {
|
||||
'FIXME': 1
|
||||
};
|
||||
|
||||
grunt.registerTask('todos', function () {
|
||||
var files = grunt.file.expand([
|
||||
'src/kibana/**/*.js',
|
||||
'!src/kibana/bower_components',
|
||||
'test/unit/specs/**/*.js'
|
||||
]);
|
||||
var matches = [];
|
||||
|
||||
var currentFile = null;
|
||||
if (grunt.file.exists(TODO_FILENAME)) {
|
||||
currentFile = grunt.file.read(TODO_FILENAME);
|
||||
}
|
||||
|
||||
Promise.map(files, function (path) {
|
||||
// grunt passes back these file names relative to the root... not
|
||||
// what we want when we are calling fs.readFile
|
||||
var absPath = absolute(path);
|
||||
|
||||
return readFileAsync(absPath, 'utf8')
|
||||
.then(function (file) {
|
||||
return file.split(NEWLINE_RE);
|
||||
})
|
||||
.each(function (line, i) {
|
||||
var match = line.match(TODO_RE);
|
||||
if (!match) return;
|
||||
|
||||
matches.push({
|
||||
type: match[1],
|
||||
msg: match[2],
|
||||
path: path,
|
||||
line: i + 1
|
||||
});
|
||||
});
|
||||
}, { concurrency: 50 })
|
||||
.then(function () {
|
||||
var newFileLines = [
|
||||
'# TODO items',
|
||||
'> Automatically extracted',
|
||||
''
|
||||
];
|
||||
|
||||
var groupedByPath = _.groupBy(matches, 'path');
|
||||
|
||||
Object.keys(groupedByPath)
|
||||
.sort(function (a, b) {
|
||||
var aChunks = a.split(path.sep);
|
||||
var bChunks = b.split(path.sep);
|
||||
|
||||
// compare the paths chunk by chunk
|
||||
for (var i = 0; i < aChunks.length; i++) {
|
||||
if (aChunks[i] === bChunks[i]) continue;
|
||||
return aChunks[i].localeCompare(bChunks[i] || '');
|
||||
}
|
||||
})
|
||||
.forEach(function (path) {
|
||||
newFileLines.push(
|
||||
' - **' +
|
||||
'[' + path + ']' +
|
||||
'(https://github.com/elasticsearch/kibana4/blob/master/' + path + ')' +
|
||||
'**'
|
||||
);
|
||||
|
||||
_(groupedByPath[path])
|
||||
.sortBy(function (match) {
|
||||
return TYPE_PRIORITIES[match.type] || 0;
|
||||
})
|
||||
.each(function (match) {
|
||||
var priority = TYPE_PRIORITIES[match.type] || 0;
|
||||
|
||||
newFileLines.push(
|
||||
' - ' + (priority ? match.type + ' – [ ] ' : '') + match.msg
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
var newFile = newFileLines.join('\n');
|
||||
|
||||
if (newFile !== currentFile) {
|
||||
grunt.log.ok('Committing updated TODO.md');
|
||||
grunt.file.write(TODO_FILENAME, newFile);
|
||||
return spawnAsync({
|
||||
cmd: 'git',
|
||||
args: ['add', absolute(TODO_FILENAME)]
|
||||
});
|
||||
} else {
|
||||
grunt.log.ok('No changes to commit to TODO.md');
|
||||
}
|
||||
})
|
||||
.nodeify(this.async());
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue