Skip to content

kaiosilveira/refactoring-catalog-cli

Repository files navigation

Command Line Interface tools to assist in the development of my refactoring catalog work.

Continuous Integration Commitizen friendly Minimum node.js version Minimum yarn version

Refactoring catalog CLI

Command line interface created to assist in the developments of @kaiosilveira/refactoring, a working implementation of the Refactoring Catalog described in Martin Fowler's homonymous book.

Installation

npm i @kaiosilveira/refactoring-catalog-cli

PS: External installations are blocked and require authorization. Contact me if you're interested on using it.

Available commands

prepare-repository -r <repository_name>

Uses Octokit to:

  • update the repository's description, tags, and URL on GitHub
  • update the README.md file with the repository name
  • update package.json with the repository name and URL

Sample usage:

npx @kaiosilveira/refactoring-catalog-cli prepare-repository -r rename-field

PS: an environment variable named GITHUB_TOKEN is needed. This should be a personal GitHub Access Token.

generate-cmt-table -r <repository_name>

Sample usage:

 npx @kaiosilveira/refactoring-catalog-cli generate-cmt-table -r rc-cli

The output will be a markdown table containing a list of commits, each row containing the commit's SHA, a remote link to it, and its description. Example:

Commit SHA Message
c96ddbc ✨ feat: add function to map commit text to a diff obj
23960a9 ✨ feat: add function to map commit history to diff objects
4b2c203 ✨ feat: add function to generate commit diff markdown
9e8debe ✨ feat: add function to fetch reversed cmt history with patch
8e95ae8 🤖 chore: bump js target to ES6

generate-diff -f <first_commit_SHA> -l <last_commit_SHA>

npx @kaiosilveira/refactoring-catalog-cli generate-diff -f HEAD~5 -l HEAD~1 > TEST.md

Generates a formatted diff of a range of commits, including their patches. Sample output:


  • assigning-to-input-param: rename inputValue to result:
+++ b/src/assigning-to-input-param/index.js
@@ -1,6 +1,6 @@
 export function discount(originalInputValue, quantity) {
-  let inputValue = originalInputValue;
-  if (inputValue > 50) inputValue = inputValue - 2;
-  if (quantity > 100) inputValue = inputValue - 1;
-  return inputValue;
+  let result = originalInputValue;
+  if (result > 50) result = result - 2;
+  if (quantity > 100) result = result - 1;
+  return result;
 }
  • assigning-to-input-param: rename originalInputValue to inputValue:
+++ b/src/assigning-to-input-param/index.js
@@ -1,5 +1,5 @@
-export function discount(originalInputValue, quantity) {
-  let result = originalInputValue;
+export function discount(inputValue, quantity) {
+  let result = inputValue;
   if (result > 50) result = result - 2;
   if (quantity > 100) result = result - 1;
   return result;