|
| 1 | +[](https://github.com/kaiosilveira/refactoring-catalog-template/actions/workflows/ci.yml) |
| 2 | + |
| 3 | +# Refactoring catalog repository template |
| 4 | + |
| 5 | +This is a quick template to help me get a new refactoring repo going. |
| 6 | + |
| 7 | +## Things to do after creating a repo off of this template |
| 8 | + |
| 9 | +1. Run `GITHUB_TOKEN=$(gh auth token) yarn tools:cli prepare-repository -r <repo_name>`. It will: |
| 10 | + |
| 11 | +- Update the `README.md` file with the actual repository name, CI badge, and commit history link |
| 12 | +- Update `package.json` with the repository's name and remote URL |
| 13 | +- Update the repo's homepage on GitHub with: |
| 14 | + - A description |
| 15 | + - A website link to https://github.com/kaiosilveira/refactoring |
| 16 | + - The following labels: javascript, refactoring, [REPOSITORY_NAME] |
| 17 | + |
| 18 | +2. Replace the lorem ipsum text sections below with actual text |
| 19 | + |
| 20 | +## Useful commands |
| 21 | + |
| 22 | +- Generate markdown containing a diff with patch information based on a range of commits: |
| 23 | + |
| 24 | +```bash |
| 25 | +yarn tools:cli generate-diff -f <first_commit_sha> -l <last_commit_sha> |
| 26 | +``` |
| 27 | + |
| 28 | +- To generate the commit history table for the last section, including the correct links: |
| 29 | + |
| 30 | +```bash |
| 31 | +yarn tools:cli generate-cmt-table -r [REPOSITORY_NAME] |
| 32 | +``` |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +ℹ️ _This repository is part of my Refactoring catalog based on Fowler's book with the same title. Please see [kaiosilveira/refactoring](https://github.com/kaiosilveira/refactoring) for more details._ |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +# Refactoring name |
| 41 | + |
| 42 | +**Formerly: Old name** |
| 43 | + |
| 44 | +<table> |
| 45 | +<thead> |
| 46 | +<th>Before</th> |
| 47 | +<th>After</th> |
| 48 | +</thead> |
| 49 | +<tbody> |
| 50 | +<tr> |
| 51 | +<td> |
| 52 | + |
| 53 | +```javascript |
| 54 | +result = initial.code; |
| 55 | +``` |
| 56 | + |
| 57 | +</td> |
| 58 | + |
| 59 | +<td> |
| 60 | + |
| 61 | +```javascript |
| 62 | +result = newCode(); |
| 63 | + |
| 64 | +function newCode() { |
| 65 | + return 'new code'; |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +</td> |
| 70 | +</tr> |
| 71 | +</tbody> |
| 72 | +</table> |
| 73 | + |
| 74 | +**Inverse of: [Another refactoring](https://github.com/kaiosilveira/refactoring)** |
| 75 | + |
| 76 | +**Refactoring introduction and motivation** dolore sunt deserunt proident enim excepteur et cillum duis velit dolor. Aute proident laborum officia velit culpa enim occaecat officia sunt aute labore id anim minim. Eu minim esse eiusmod enim nulla Lorem. Enim velit in minim anim anim ad duis aute ipsum voluptate do nulla. Ad tempor sint dolore et ullamco aute nulla irure sunt commodo nulla aliquip. |
| 77 | + |
| 78 | +## Working example |
| 79 | + |
| 80 | +**Working example general explanation** proident reprehenderit mollit non voluptate ea aliquip ad ipsum anim veniam non nostrud. Cupidatat labore occaecat labore veniam incididunt pariatur elit officia. Aute nisi in nulla non dolor ullamco ut dolore do irure sit nulla incididunt enim. Cupidatat aliquip minim culpa enim. Fugiat occaecat qui nostrud nostrud eu exercitation Lorem pariatur fugiat ea consectetur pariatur irure. Officia dolore veniam duis duis eu eiusmod cupidatat laboris duis ad proident adipisicing. Minim veniam consectetur ut deserunt fugiat id incididunt reprehenderit. |
| 81 | + |
| 82 | +### Test suite |
| 83 | + |
| 84 | +Occaecat et incididunt aliquip ex id dolore. Et excepteur et ea aute culpa fugiat consectetur veniam aliqua. Adipisicing amet reprehenderit elit qui. |
| 85 | + |
| 86 | +```javascript |
| 87 | +describe('functionBeingRefactored', () => { |
| 88 | + it('should work', () => { |
| 89 | + expect(0).toEqual(1); |
| 90 | + }); |
| 91 | +}); |
| 92 | +``` |
| 93 | + |
| 94 | +Magna ut tempor et ut elit culpa id minim Lorem aliqua laboris aliqua dolor. Irure mollit ad in et enim consequat cillum voluptate et amet esse. Fugiat incididunt ea nulla cupidatat magna enim adipisicing consequat aliquip commodo elit et. Mollit aute irure consequat sunt. Dolor consequat elit voluptate aute duis qui eu do veniam laborum elit quis. |
| 95 | + |
| 96 | +### Steps |
| 97 | + |
| 98 | +**Step 1 description** mollit eu nulla mollit irure sint proident sint ipsum deserunt ad consectetur laborum incididunt aliqua. Officia occaecat deserunt in aute veniam sunt ad fugiat culpa sunt velit nulla. Pariatur anim sit minim sit duis mollit. |
| 99 | + |
| 100 | +```diff |
| 101 | +diff --git a/src/price-order/index.js b/src/price-order/index.js |
| 102 | +@@ -3,6 +3,11 @@ |
| 103 | +-module.exports = old; |
| 104 | ++module.exports = new; |
| 105 | +``` |
| 106 | + |
| 107 | +**Step n description** mollit eu nulla mollit irure sint proident sint ipsum deserunt ad consectetur laborum incididunt aliqua. Officia occaecat deserunt in aute veniam sunt ad fugiat culpa sunt velit nulla. Pariatur anim sit minim sit duis mollit. |
| 108 | + |
| 109 | +```diff |
| 110 | +diff --git a/src/price-order/index.js b/src/price-order/index.js |
| 111 | +@@ -3,6 +3,11 @@ |
| 112 | +-module.exports = old; |
| 113 | ++module.exports = new; |
| 114 | +``` |
| 115 | + |
| 116 | +And that's it! |
| 117 | + |
| 118 | +### Commit history |
| 119 | + |
| 120 | +Below there's the commit history for the steps detailed above. |
| 121 | + |
| 122 | +| Commit SHA | Message | |
| 123 | +| --------------------------------------------------------------------------- | ------------------------ | |
| 124 | +| [cmt-sha-1](https://github.com/kaiosilveira/[REPOSITORY_NAME]/commit-SHA-1) | description of commit #1 | |
| 125 | +| [cmt-sha-2](https://github.com/kaiosilveira/[REPOSITORY_NAME]/commit-SHA-2) | description of commit #2 | |
| 126 | +| [cmt-sha-n](https://github.com/kaiosilveira/[REPOSITORY_NAME]/commit-SHA-n) | description of commit #n | |
| 127 | + |
| 128 | +For the full commit history for this project, check the [Commit History tab](https://github.com/kaiosilveira/[REPOSITORY_NAME]/commits/main). |
0 commit comments