Yanick Champoux 2021-10-28 11:03:36 -04:00
parent d389a4f9b6
commit e381929bc3
3 changed files with 61 additions and 0 deletions

View File

@ -11,9 +11,13 @@
"license": "ISC",
"dependencies": {
"@gitgraph/node": "^0.1.18",
"chalk": "^4.1.2",
"columnify": "^1.5.4",
"inquirer": "^7.3.3",
"lodash": "^4.17.21",
"simple-git": "^2.47.0",
"stringify-tree": "^1.1.1",
"updeep": "^1.2.1",
"yargs": "^16.2.0",
"yurnalist": "^2.1.0"
}

51
src/commands/status.js Normal file
View File

@ -0,0 +1,51 @@
const Git = require('simple-git');
const inquirer = require('inquirer');
const report = require('yurnalist');
const _ = require('lodash');
const u = require('updeep');
const columnify = require('columnify');
const chalk = require('chalk');
module.exports = async (yargs) => {
const config = (await Git().listConfig('local')).all;
let tree = Object.entries(config).reduce(
(accum, [key,value]) => u.updateIn(key,value,accum), {}
);
const branches = {};
const current = (await Git().raw('branch','--show-current')).replace("\n",'');
for( const branch in tree.branch ) {
const entry = tree.branch[branch];
if( 'mikado-done' in entry ) {
let deps = entry['mikado-dependency'];
if(!Array.isArray(deps)) deps = [ deps ].filter(x=>x);
branches[branch] = {
bullet: branch === current ? '*': ' ',
dependencies: deps.length > 0 ? deps.map( dep => chalk.magenta(dep) ): '',
name: chalk.blue.bold(branch),
upstream: entry['mikado-upstream'],
base: chalk.cyan.italic(entry['mikado-base'] ?? ''),
done: entry['mikado-done'],
}
}
}
console.log( "\nMikado status\n" );
console.log(
columnify( Object.values(branches), {
showHeaders: false,
columns: [ 'bullet', 'name', 'base', 'dependencies' ],
config: {
base: { minWidth: 10 },
}
} )
)
}

View File

@ -1,9 +1,15 @@
const yargs = require("yargs");
const new_branch = require("./commands/new_branch");
const status = require("./commands/status");
yargs
.scriptName("git-mikado")
.showHelpOnFail(true)
.command(
"status",
"show status of all mikado branches",
status
)
.command(
"new [branch]",
"create new mikado branch",