├── dossier-demo.gif ├── package.json ├── LICENSE ├── .gitignore ├── README.md ├── src ├── utilities.js └── cli.js └── CODE_OF_CONDUCT.md /dossier-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/captainsafia/dossier/HEAD/dossier-demo.gif -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@captainsafia/dossier", 3 | "version": "1.0.1", 4 | "description": "Generate a command line report for a git repository", 5 | "main": "src/utilities.js", 6 | "bin": { 7 | "dossier": "src/cli.js" 8 | }, 9 | "keywords": [ 10 | "git", 11 | "stats", 12 | "reporting", 13 | "developer experience" 14 | ], 15 | "author": "Safia Abdalla ", 16 | "license": "MIT", 17 | "dependencies": { 18 | "colors": "^1.1.2", 19 | "commander": "^2.9.0", 20 | "gitlog": "^2.4.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Safia Abdalla 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dossier 2 | dossier is a command line utility that generates a report from any git repository 3 | that utilizes the [Conventional Changelog Standard](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md). Technically, this tool can be used on any commit message convention that denotes 4 | commit type with a prefix. Currently, dossier generates the following statistics: 5 | 6 | - Commit counts by prefix 7 | - Top contributor by prefix 8 | - Most frequent commit day by prefix 9 | 10 | If you're interested in seeing more statistics reflected in dossier, you can 11 | submit an issue. 12 | 13 | dossier aims to provide an output that can be easily piped and parsed 14 | by other utilities in your workflow. 15 | 16 | ### Installation 17 | 18 | ``` 19 | npm install --global @captainsafia/dossier 20 | ``` 21 | 22 | ### Usage 23 | 24 | ``` 25 | Usage: dossier [options] 26 | 27 | Options: 28 | 29 | -h, --help output usage information 30 | -V, --version output the version number 31 | -c, --commits Number of commits to analyze 32 | -p, --prefixes Conventional changelog prefixes used 33 | ``` 34 | 35 | ![Dossier Demo](dossier-demo.gif) 36 | -------------------------------------------------------------------------------- /src/utilities.js: -------------------------------------------------------------------------------- 1 | function mostFrequent(array) { 2 | return array.sort(function(a, b) { 3 | return array.filter(function(element) { 4 | return element === a; 5 | }).length - array.filter(function(element) { 6 | return element === b; 7 | }).length 8 | }).pop(); 9 | } 10 | 11 | function getCounts(commits, prefix) { 12 | return commits.filter(function(commit) { 13 | return commit.subject.toLowerCase().startsWith(prefix.toLowerCase()); 14 | }).length; 15 | } 16 | 17 | function getMostFrequentContributor(commits, prefix) { 18 | const contributors = commits.filter(function(commit) { 19 | return commit.subject.toLowerCase().startsWith(prefix.toLowerCase()); 20 | }).map(function(commit) { 21 | return commit.authorName.replace('@end@', ''); 22 | }); 23 | return mostFrequent(contributors); 24 | } 25 | 26 | function getMostFrequentDay(commits, prefix) { 27 | const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 28 | 'Thursday', 'Friday', 'Saturday']; 29 | const dates = commits.filter(function(commit) { 30 | return commit.subject.toLowerCase().startsWith(prefix.toLowerCase()); 31 | }).map(function(commit) { 32 | return new Date(commit.authorDate).getDay(); 33 | }); 34 | return days[mostFrequent(dates)]; 35 | } 36 | 37 | module.exports = { 38 | getCounts, 39 | getMostFrequentContributor, 40 | getMostFrequentDay 41 | }; 42 | -------------------------------------------------------------------------------- /src/cli.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | const log = require('gitlog'); 4 | const utils = require('./utilities'); 5 | const program = require('commander'); 6 | const colors = require('colors'); 7 | 8 | function parsePrefixes(prefixes) { 9 | return prefixes.split(','); 10 | } 11 | 12 | program 13 | .version('1.0.0') 14 | .option('-c, --commits ', 'Number of commits to analyze', parseInt) 15 | .option('-p, --prefixes ', 'Conventional changelog prefixes used', parsePrefixes) 16 | .option('-m, --maxBuffer [n]', 'Optional maxBuffer to be used in process. Defaults to 500KB. Increase if maxBuffer is exceeded', value => parseInt(value), 500) 17 | .parse(process.argv); 18 | 19 | if (program.commits && program.prefixes) { 20 | log({ 21 | repo: process.cwd(), 22 | number: program.commits, 23 | fields: ['authorDate', 'abbrevHash', 'hash', 'subject', 'authorName'], 24 | execOptions: { 25 | maxBuffer: 1024 * program.maxBuffer 26 | } 27 | }, function(error, commits) { 28 | if (error) return console.log(colors.red(error)); 29 | 30 | console.log('Prefixed Commit Counts'); 31 | program.prefixes.map(function(prefix) { 32 | console.log('-', utils.getCounts(commits, prefix), prefix, 'commits'); 33 | }); 34 | console.log('\n'); 35 | 36 | program.prefixes.map(function(prefix) { 37 | const contributor = utils.getMostFrequentContributor(commits, prefix); 38 | console.log('Top', prefix, 'Contributor:', contributor); 39 | }); 40 | console.log('\n'); 41 | 42 | program.prefixes.map(function(prefix) { 43 | const date = utils.getMostFrequentDay(commits, prefix); 44 | console.log('Top', prefix, 'Commit Day:', date); 45 | }); 46 | }); 47 | } else { 48 | program.help(); 49 | } 50 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at safia@safia.rocks. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | --------------------------------------------------------------------------------