versioncommit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ {
2
+ // Use o IntelliSense para saber mais sobre os atributos possíveis.
3
+ // Focalizar para exibir as descrições dos atributos existentes.
4
+ // Para obter mais informações, acesse: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "type": "node",
9
+ "request": "launch",
10
+ "name": "mac",
11
+ "skipFiles": [
12
+ "<node_internals>/**"
13
+ ],
14
+ "program": "${workspaceFolder}/app.js",
15
+ //"runtimeExecutable": "/usr/local/bin/node"
16
+ "runtimeExecutable": "/Users/danilosouza/.nvm/versions/node/v16.14.0/bin/node"
17
+ },
18
+ {
19
+ "type": "node",
20
+ "request": "launch",
21
+ "name": "windows",
22
+ "skipFiles": [
23
+ "<node_internals>/**"
24
+ ],
25
+ "program": "${workspaceFolder}/app.js"
26
+ }
27
+ ]
28
+ }
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # Version Commit CLI
2
+
3
+ `version-commit` is a command-line tool (CLI) that automatically generates versions based on GitHub repository commits.
4
+
5
+ ## Installation
6
+
7
+ To install `version-commit`, run the following command:
8
+
9
+ ```sh
10
+ npm install -g https://github.com/danilosoftwares/versionCommit.git
11
+ ```
12
+
13
+ This will install the tool globally, allowing you to use it from anywhere in the terminal.
14
+
15
+ ## Usage
16
+
17
+ `version-commit` requires a **GitHub token** and the **repository name** to generate the version based on commits.
18
+
19
+ ### Command:
20
+ ```sh
21
+ version-commit {token} {repository} {branch}
22
+ ```
23
+
24
+ ### Example simple:
25
+ ```sh
26
+ version-commit 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
27
+ danilosoftwares/BloomMany
28
+ ```
29
+
30
+ ### Example with branch:
31
+ ```sh
32
+ version-commit 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
33
+ danilosoftwares/BloomMany
34
+ develop
35
+ ```
36
+
37
+ ### Parameters:
38
+ - `{token}`: Your **GitHub Personal Access Token (PAT)**, required for authentication and repository access.
39
+ - `{repository}`: The repository name in the format `user/repo` (e.g., `danilosoftwares/ReactCapilar`).
40
+ - `{branch}`: The branch name such as `develop`.
41
+
42
+ ## How It Works
43
+
44
+ 1. `version-commit` accesses the specified repository and analyzes its commits.
45
+ 2. Based on commit patterns (`fix:`, `feat:`, etc.), it generates a version following the **Semantic Versioning (SemVer)** standard.
46
+ 3. The generated version is displayed in the terminal.
47
+
48
+ ## Example of Generated Version
49
+
50
+ If the latest commits are:
51
+ ```sh
52
+ 1.0.0: Initial release.
53
+ 1.1.0: feat: Added new functionality, compatible with 1.0.0.
54
+ 1.1.1: fix: Bug fix in 1.1.0.
55
+ 2.0.0: BREAKING CHANGE: Incompatible API changes, breaking compatibility with 1.x.
56
+ ```
57
+ The generated version might be **2.0.0** (depending on the versioning rules used).
58
+
59
+ ## GitHub Token Permissions
60
+
61
+ The provided token should have at least the following permissions:
62
+ - `repo` (for private repositories)
63
+ - `public_repo` (for public repositories)
64
+
65
+ If you need to generate a token, visit:
66
+ 🔗 [GitHub Token Settings](https://github.com/settings/tokens)
67
+
68
+ ## What is Semantic Version ?
69
+
70
+ Semantic Versioning (SemVer) is a software version control scheme that uses a structure of three numbers separated by periods to indicate the nature of changes in a project: MAJOR.MINOR.PATCH. Each number has a specific meaning, indicating whether the changes are compatible or not with previous versions.
71
+
72
+ SemVer Structure and Rules:
73
+
74
+ MAJOR (Major Version):
75
+
76
+ Increments when incompatible changes are made to the software's API. This means that when updating to this new version, code that depends on the previous version may need to be modified to work correctly.
77
+
78
+ MINOR (Minor Version):
79
+
80
+ Increments when new functionality is added in a way that is compatible with previous versions. The existing API continues to work, but with additional features.
81
+
82
+ PATCH (Patch Version):
83
+
84
+ Increments when bug fixes or minor adjustments that do not change the API are made.
85
+
86
+ Example Commits:
87
+ ```sh
88
+ 1.0.0: Initial release.
89
+ 1.1.0: feat: Added new functionality, compatible with 1.0.0.
90
+ 1.1.1: fix: Bug fix in 1.1.0.
91
+ 2.0.0: BREAKING CHANGE: Incompatible API changes, breaking compatibility with 1.x.
92
+ ```
93
+
94
+ ![](flow.svg)
95
+
96
+ ## Contribution
97
+
98
+ If you find any bugs or have suggestions, feel free to open an **Issue** or submit a **Pull Request** in the official repository:
99
+ 🔗 [GitHub Repo](https://github.com/danilosoftwares/versionCommit)
100
+
101
+ ## License
102
+
103
+ This project is distributed under the MIT license. See the repository for more details.
104
+
105
+ ---
106
+
107
+ Now you can automatically generate versions based on your repository commits! 🚀
108
+
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ const main = require('../lib/app.js').main;
4
+ main();
package/flow.svg ADDED
@@ -0,0 +1,3 @@
1
+ <?xml version="1.0" encoding="utf-8" standalone="yes"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg width="780" height="499" viewBox="0 0 780 499" style="fill:none;stroke:none;fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><style class="text-font-style fontImports" data-font-family="Roboto">@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&amp;display=block');</style><g id="items" style="isolation: isolate"><g id="blend" style="mix-blend-mode: normal"><g id="g-root-cp_0_g-0_1ltn7rmddhl34-fill" data-item-order="999646233" transform="translate(26.130859375, 248.5)"></g><g id="g-root-cp_1_g-1_1cy07iqddhlvu-fill" data-item-order="999646252" transform="translate(65.13101196289062, 125)"><g id="cp_1_g-1_1cy07iqddhlvu-fill" stroke="none" fill="#3e4e69"><g><path d="M 100 55C 100 66.244 94.5 77.5875 89 86L 55.816 132.848C 55.4175 133.4106 54.5825 133.4106 54.184 132.848L 21 86C 14.5 77 10 66.7284 10 55C 10 30.1472 30.1472 10 55 10C 79.8528 10 100 30.1472 100 55ZM 55 91C 74.8822 91 91 74.8822 91 55C 91 35.1177 74.8822 19 55 19C 35.1177 19 19 35.1177 19 55C 19 74.8822 35.1177 91 55 91Z"></path></g></g><g id="cp_1_g-1_1cy07iqddhlvu-fill" stroke="none" fill="#3e4e69"><g><path d="M 55 187C 61.6274 187 67 181.6274 67 175C 67 168.3726 61.6274 163 55 163C 48.3726 163 43 168.3726 43 175C 43 181.6274 48.3726 187 55 187ZM 55 181C 58.3137 181 61 178.3137 61 175C 61 171.6863 58.3137 169 55 169C 51.6863 169 49 171.6863 49 175C 49 178.3137 51.6863 181 55 181Z"></path></g></g></g><g id="g-root-cp_2_g-2_18i6peaddhmo5-fill" data-item-order="999646256" transform="translate(245.1309814453125, 278)"><g id="cp_2_g-2_18i6peaddhmo5-fill" stroke="none" fill="#3b5649"><g><path d="M 100 142.000369C 100 130.756469 94.5 119.412869 89 111.000369L 55.816 64.152469C 55.4175 63.589769 54.5825 63.589769 54.184 64.152469L 21 111.000369C 14.5 120.000369 10 130.271969 10 142.000369C 10 166.853269 30.1472 187.000369 55 187.000369C 79.8528 187.000369 100 166.853269 100 142.000369ZM 55 106.000369C 74.8822 106.000369 91 122.118169 91 142.000369C 91 161.882669 74.8822 178.000369 55 178.000369C 35.1177 178.000369 19 161.882669 19 142.000369C 19 122.118169 35.1177 106.000369 55 106.000369Z"></path></g></g><g id="cp_2_g-2_18i6peaddhmo5-fill" stroke="none" fill="#3b5649"><g><path d="M 55 34C 61.6274 34 67 28.6274 67 22C 67 15.3726 61.6274 10 55 10C 48.3726 10 43 15.3726 43 22C 43 28.6274 48.3726 34 55 34ZM 55 28C 58.3137 28 61 25.3137 61 22C 61 18.6863 58.3137 16 55 16C 51.6863 16 49 18.6863 49 22C 49 25.3137 51.6863 28 55 28Z"></path></g></g></g><g id="g-root-cp_3_g-3_142zocyddhkao-fill" data-item-order="999646262" transform="translate(425.1309814453125, 125)"><g id="cp_3_g-3_142zocyddhkao-fill" stroke="none" fill="#4b533a"><g><path d="M 100 55C 100 66.244 94.5 77.5875 89 86L 55.816 132.848C 55.4175 133.4106 54.5825 133.4106 54.184 132.848L 21 86C 14.5 77 10 66.7284 10 55C 10 30.1472 30.1472 10 55 10C 79.8528 10 100 30.1472 100 55ZM 55 91C 74.8822 91 91 74.8822 91 55C 91 35.1177 74.8822 19 55 19C 35.1177 19 19 35.1177 19 55C 19 74.8822 35.1177 91 55 91Z"></path></g></g><g id="cp_3_g-3_142zocyddhkao-fill" stroke="none" fill="#4b533a"><g><path d="M 55 187C 61.6274 187 67 181.6274 67 175C 67 168.3726 61.6274 163 55 163C 48.3726 163 43 168.3726 43 175C 43 181.6274 48.3726 187 55 187ZM 55 181C 58.3137 181 61 178.3137 61 175C 61 171.6863 58.3137 169 55 169C 51.6863 169 49 171.6863 49 175C 49 178.3137 51.6863 181 55 181Z"></path></g></g></g><g id="g-root-cp_4_g-4_v7co42ddhl3f-fill" data-item-order="999646268" transform="translate(605.1309814453125, 278)"><g id="cp_4_g-4_v7co42ddhl3f-fill" stroke="none" fill="#68403f"><g><path d="M 100 142.000369C 100 130.756469 94.5 119.412869 89 111.000369L 55.816 64.152469C 55.4175 63.589769 54.5825 63.589769 54.184 64.152469L 21 111.000369C 14.5 120.000369 10 130.271969 10 142.000369C 10 166.853269 30.1472 187.000369 55 187.000369C 79.8528 187.000369 100 166.853269 100 142.000369ZM 55 106.000369C 74.8822 106.000369 91 122.118169 91 142.000369C 91 161.882669 74.8822 178.000369 55 178.000369C 35.1177 178.000369 19 161.882669 19 142.000369C 19 122.118169 35.1177 106.000369 55 106.000369Z"></path></g></g><g id="cp_4_g-4_v7co42ddhl3f-fill" stroke="none" fill="#68403f"><g><path d="M 55 34C 61.6274 34 67 28.6274 67 22C 67 15.3726 61.6274 10 55 10C 48.3726 10 43 15.3726 43 22C 43 28.6274 48.3726 34 55 34ZM 55 28C 58.3137 28 61 25.3137 61 22C 61 18.6863 58.3137 16 55 16C 51.6863 16 49 18.6863 49 22C 49 25.3137 51.6863 28 55 28Z"></path></g></g></g><g id="g-root-tx_evolutio_hvw5qqddhmoe-fill" data-item-order="1000000000" transform="translate(152, 2)"><g id="tx_evolutio_hvw5qqddhmoe-fill" stroke="none" fill="#f4f4f4"><g><text style="font: bold 25px Roboto, sans-serif; white-space: pre;" font-weight="bold" font-size="25px" font-family="Roboto, sans-serif"><tspan x="17.28" y="42" dominant-baseline="ideographic">Evolution of Software Release Versions</tspan></text></g></g></g><g id="g-root-tx_200_qoesk2ddkd1p-fill" data-item-order="1000000000" transform="translate(620, 98)"><g id="tx_200_qoesk2ddkd1p-fill" stroke="none" fill="#fb6762"><g><text style="font: bold 20px Roboto, sans-serif; white-space: pre;" font-weight="bold" font-size="20px" font-family="Roboto, sans-serif"><tspan x="16.98" y="34" dominant-baseline="ideographic">2.0.0</tspan></text></g></g></g><g id="g-root-tx_110_detpg2ddizgp-fill" data-item-order="1000000000" transform="translate(260, 134)"><g id="tx_110_detpg2ddizgp-fill" stroke="none" fill="#43dd93"><g><text style="font: bold 20px Roboto, sans-serif; white-space: pre;" font-weight="bold" font-size="20px" font-family="Roboto, sans-serif"><tspan x="16.98" y="34" dominant-baseline="ideographic">1.1.0</tspan></text></g></g></g><g id="g-root-ic_load_8x4s2addkfex-fill" data-item-order="1000000000" transform="translate(86.1309814453125, 146)"></g><g id="g-root-ic_bug_mgpgk2ddkf7v-fill" data-item-order="1000000000" transform="translate(446.1309814453125, 146)"></g><g id="g-root-tx_breaking_m8lafmddkdty-fill" data-item-order="1000000000" transform="translate(572, 134)"><g id="tx_breaking_m8lafmddkdty-fill" stroke="none" fill="#f4f4f4"><g><text style="font: 15px Roboto, sans-serif; white-space: pre;" font-size="15px" font-family="Roboto, sans-serif"><tspan x="17.62" y="28" dominant-baseline="ideographic">BREAKING CHANGE: </tspan><tspan x="29.79" y="46" dominant-baseline="ideographic">Incompatible API </tspan><tspan x="26.46" y="64" dominant-baseline="ideographic">changes, breaking </tspan><tspan x="16.15" y="82" dominant-baseline="ideographic">compatibility with 1.x</tspan></text></g></g></g><g id="g-root-tx_addednew_8z07bmddj08y-fill" data-item-order="1000000000" transform="translate(200, 170)"><g id="tx_addednew_8z07bmddj08y-fill" stroke="none" fill="#f4f4f4"><g><text style="font: 15px Roboto, sans-serif; white-space: pre;" font-size="15px" font-family="Roboto, sans-serif"><tspan x="17.57" y="28" dominant-baseline="ideographic">Added new functionality, </tspan><tspan x="27.2" y="46" dominant-baseline="ideographic">compatible with 1.0.0</tspan></text></g></g></g><g id="g-root-tx_100_dcya6qddkemn-fill" data-item-order="1000000000" transform="translate(80, 374)"><g id="tx_100_dcya6qddkemn-fill" stroke="none" fill="#4f91fc"><g><text style="font: bold 20px Roboto, sans-serif; white-space: pre;" font-weight="bold" font-size="20px" font-family="Roboto, sans-serif"><tspan x="16.98" y="34" dominant-baseline="ideographic">1.0.0</tspan></text></g></g></g><g id="g-root-ic_new_58mc2ddhlvr-fill" data-item-order="1000000000" transform="translate(266.1310119628906, 386)"></g><g id="g-root-tx_111_vccgsyddkef5-fill" data-item-order="1000000000" transform="translate(440, 374)"><g id="tx_111_vccgsyddkef5-fill" stroke="none" fill="#a6da37"><g><text style="font: bold 20px Roboto, sans-serif; white-space: pre;" font-weight="bold" font-size="20px" font-family="Roboto, sans-serif"><tspan x="16.98" y="34" dominant-baseline="ideographic">1.1.1</tspan></text></g></g></g><g id="g-root-ic_aler_3d72qddj11n-fill" data-item-order="1000000000" transform="translate(626.1309814453125, 386)"></g><g id="g-root-tx_initialr_hsrsb6ddkem8-fill" data-item-order="1000000000" transform="translate(62, 410)"><g id="tx_initialr_hsrsb6ddkem8-fill" stroke="none" fill="#f4f4f4"><g><text style="font: 15px Roboto, sans-serif; white-space: pre;" font-size="15px" font-family="Roboto, sans-serif"><tspan x="13.77" y="31" dominant-baseline="ideographic">Initial release</tspan></text></g></g></g><g id="g-root-tx_bugfixin_mgpgk2ddkf7u-fill" data-item-order="1000000000" transform="translate(416, 410)"><g id="tx_bugfixin_mgpgk2ddkf7u-fill" stroke="none" fill="#f4f4f4"><g><text style="font: 15px Roboto, sans-serif; white-space: pre;" font-size="15px" font-family="Roboto, sans-serif"><tspan x="14.95" y="31" dominant-baseline="ideographic">Bug fix in 1.1.0</tspan></text></g></g></g><g id="g-root-cp_0_g-0_1ltn7rmddhl34-stroke" data-item-order="999646233" transform="translate(26.130859375, 248.5)"><g id="cp_0_g-0_1ltn7rmddhl34-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#b7b7b7" stroke-width="2"><g><path d="M 645.869141 51.5L 717.869141 51.5M 106 51L 262 51M 286 51L 442 51M 274 63.5L 274 93M 454 10L 454 39.5M 466 51L 622 51M 634 63.5L 634 93M 10 51L 82 51M 94 10L 94 39.5"></path></g></g></g><g id="g-root-cp_1_g-1_1cy07iqddhlvu-stroke" data-item-order="999646252" transform="translate(65.13101196289062, 125)"><g id="cp_1_g-1_1cy07iqddhlvu-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#4f91fc" stroke-width="2"><g><path d="M 100 55C 100 66.244 94.5 77.5875 89 86L 55.816 132.848C 55.4175 133.4106 54.5825 133.4106 54.184 132.848L 21 86C 14.5 77 10 66.7284 10 55C 10 30.1472 30.1472 10 55 10C 79.8528 10 100 30.1472 100 55ZM 55 91C 74.8822 91 91 74.8822 91 55C 91 35.1177 74.8822 19 55 19C 35.1177 19 19 35.1177 19 55C 19 74.8822 35.1177 91 55 91Z"></path></g></g><g id="cp_1_g-1_1cy07iqddhlvu-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#4f91fc" stroke-width="2"><g><path d="M 55 187C 61.6274 187 67 181.6274 67 175C 67 168.3726 61.6274 163 55 163C 48.3726 163 43 168.3726 43 175C 43 181.6274 48.3726 187 55 187ZM 55 181C 58.3137 181 61 178.3137 61 175C 61 171.6863 58.3137 169 55 169C 51.6863 169 49 171.6863 49 175C 49 178.3137 51.6863 181 55 181Z"></path></g></g></g><g id="g-root-cp_2_g-2_18i6peaddhmo5-stroke" data-item-order="999646256" transform="translate(245.1309814453125, 278)"><g id="cp_2_g-2_18i6peaddhmo5-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#43dd93" stroke-width="2"><g><path d="M 100 142.000369C 100 130.756469 94.5 119.412869 89 111.000369L 55.816 64.152469C 55.4175 63.589769 54.5825 63.589769 54.184 64.152469L 21 111.000369C 14.5 120.000369 10 130.271969 10 142.000369C 10 166.853269 30.1472 187.000369 55 187.000369C 79.8528 187.000369 100 166.853269 100 142.000369ZM 55 106.000369C 74.8822 106.000369 91 122.118169 91 142.000369C 91 161.882669 74.8822 178.000369 55 178.000369C 35.1177 178.000369 19 161.882669 19 142.000369C 19 122.118169 35.1177 106.000369 55 106.000369Z"></path></g></g><g id="cp_2_g-2_18i6peaddhmo5-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#43dd93" stroke-width="2"><g><path d="M 55 34C 61.6274 34 67 28.6274 67 22C 67 15.3726 61.6274 10 55 10C 48.3726 10 43 15.3726 43 22C 43 28.6274 48.3726 34 55 34ZM 55 28C 58.3137 28 61 25.3137 61 22C 61 18.6863 58.3137 16 55 16C 51.6863 16 49 18.6863 49 22C 49 25.3137 51.6863 28 55 28Z"></path></g></g></g><g id="g-root-cp_3_g-3_142zocyddhkao-stroke" data-item-order="999646262" transform="translate(425.1309814453125, 125)"><g id="cp_3_g-3_142zocyddhkao-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#a6da37" stroke-width="2"><g><path d="M 100 55C 100 66.244 94.5 77.5875 89 86L 55.816 132.848C 55.4175 133.4106 54.5825 133.4106 54.184 132.848L 21 86C 14.5 77 10 66.7284 10 55C 10 30.1472 30.1472 10 55 10C 79.8528 10 100 30.1472 100 55ZM 55 91C 74.8822 91 91 74.8822 91 55C 91 35.1177 74.8822 19 55 19C 35.1177 19 19 35.1177 19 55C 19 74.8822 35.1177 91 55 91Z"></path></g></g><g id="cp_3_g-3_142zocyddhkao-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#a6da37" stroke-width="2"><g><path d="M 55 187C 61.6274 187 67 181.6274 67 175C 67 168.3726 61.6274 163 55 163C 48.3726 163 43 168.3726 43 175C 43 181.6274 48.3726 187 55 187ZM 55 181C 58.3137 181 61 178.3137 61 175C 61 171.6863 58.3137 169 55 169C 51.6863 169 49 171.6863 49 175C 49 178.3137 51.6863 181 55 181Z"></path></g></g></g><g id="g-root-cp_4_g-4_v7co42ddhl3f-stroke" data-item-order="999646268" transform="translate(605.1309814453125, 278)"><g id="cp_4_g-4_v7co42ddhl3f-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#fb6762" stroke-width="2"><g><path d="M 100 142.000369C 100 130.756469 94.5 119.412869 89 111.000369L 55.816 64.152469C 55.4175 63.589769 54.5825 63.589769 54.184 64.152469L 21 111.000369C 14.5 120.000369 10 130.271969 10 142.000369C 10 166.853269 30.1472 187.000369 55 187.000369C 79.8528 187.000369 100 166.853269 100 142.000369ZM 55 106.000369C 74.8822 106.000369 91 122.118169 91 142.000369C 91 161.882669 74.8822 178.000369 55 178.000369C 35.1177 178.000369 19 161.882669 19 142.000369C 19 122.118169 35.1177 106.000369 55 106.000369Z"></path></g></g><g id="cp_4_g-4_v7co42ddhl3f-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#fb6762" stroke-width="2"><g><path d="M 55 34C 61.6274 34 67 28.6274 67 22C 67 15.3726 61.6274 10 55 10C 48.3726 10 43 15.3726 43 22C 43 28.6274 48.3726 34 55 34ZM 55 28C 58.3137 28 61 25.3137 61 22C 61 18.6863 58.3137 16 55 16C 51.6863 16 49 18.6863 49 22C 49 25.3137 51.6863 28 55 28Z"></path></g></g></g><g id="g-root-tx_evolutio_hvw5qqddhmoe-stroke" data-item-order="1000000000" transform="translate(152, 2)"></g><g id="g-root-tx_200_qoesk2ddkd1p-stroke" data-item-order="1000000000" transform="translate(620, 98)"></g><g id="g-root-tx_110_detpg2ddizgp-stroke" data-item-order="1000000000" transform="translate(260, 134)"></g><g id="g-root-ic_load_8x4s2addkfex-stroke" data-item-order="1000000000" transform="translate(86.1309814453125, 146)"><g id="ic_load_8x4s2addkfex-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#4f91fc" stroke-width="2"><g><path d="M 32 14C 32 12.895431 32.895432 12 34 12C 35.104568 12 36 12.895431 36 14L 36 20C 36 21.104568 35.104568 22 34 22C 32.895432 22 32 21.104568 32 20ZM 18.764 21.506001C 17.982517 20.72286 17.98386 19.454483 18.767 18.673C 19.55014 17.891518 20.818516 17.89286 21.6 18.676001L 25.836 22.917999C 26.356256 23.419785 26.565285 24.163239 26.382746 24.862617C 26.200209 25.561998 25.65451 26.108469 24.955389 26.291996C 24.256268 26.475523 23.51252 26.267546 23.01 25.748001ZM 12 34C 12 32.895432 12.895431 32 14 32L 20 32C 21.104568 32 22 32.895432 22 34C 22 35.104568 21.104568 36 20 36L 14 36C 12.895431 36 12 35.104568 12 34ZM 18.257999 49.703999C 17.882446 49.328865 17.671427 48.819817 17.671427 48.289001C 17.671427 47.758183 17.882446 47.249138 18.257999 46.874001L 22.498001 42.630001C 23.278931 41.848518 24.545517 41.848072 25.327002 42.629002C 26.108484 43.409935 26.108932 44.676521 25.328001 45.458004L 21.086 49.702C 20.305553 50.483318 19.039551 50.484211 18.257999 49.703999ZM 32 48C 32 46.895432 32.895432 46 34 46C 35.104568 46 36 46.895432 36 48L 36 54C 36 55.104568 35.104568 56 34 56C 32.895432 56 32 55.104568 32 54ZM 42.799999 45.548C 42.017967 44.765968 42.017967 43.498039 42.800003 42.716003C 43.582039 41.933968 44.849968 41.933968 45.632004 42.716003L 49.875999 46.956001C 50.66135 47.735275 50.666275 49.003654 49.887001 49.789001C 49.107727 50.574352 47.839352 50.579277 47.054001 49.800003ZM 46 34C 46 32.895432 46.895432 32 48 32L 54 32C 55.104568 32 56 32.895432 56 34C 56 35.104568 55.104568 36 54 36L 48 36C 46.895432 36 46 35.104568 46 34ZM 42.436001 25.476C 42.059834 25.100784 41.848427 24.591309 41.848427 24.060001C 41.848427 23.52869 42.059834 23.019218 42.436001 22.644001L 46.674 18.4C 47.456039 17.617966 48.723969 17.617966 49.506004 18.400002C 50.288036 19.182035 50.288036 20.449966 49.506004 21.232L 45.264 25.476C 44.483002 26.256763 43.216999 26.256763 42.436001 25.476Z"></path></g></g></g><g id="g-root-ic_bug_mgpgk2ddkf7v-stroke" data-item-order="1000000000" transform="translate(446.1309814453125, 146)"><g id="ic_bug_mgpgk2ddkf7v-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#a6da37" stroke-width="2"><g><path d="M 50.999973 28.999987L 50.999973 14.333998C 50.999977 12.492682 49.507294 10.999999 47.665977 10.999999L 20.333992 10.999999C 18.492678 10.999999 16.999996 12.492682 16.999996 14.333998L 16.999996 36.999981M 28.999987 44.999977L 21.245993 44.999977C 16.399775 44.999722 12.175535 41.701466 10.999999 36.999981L 30.999987 36.999981M 38.999981 46.999977C 38.999985 50.313683 41.686272 52.999973 44.999977 52.999973C 48.313683 52.999973 50.999973 50.313683 50.999973 46.999977L 50.999973 42.999977C 50.999973 39.686272 48.313683 36.999985 44.999977 36.999985C 41.686272 36.999985 38.999985 39.686272 38.999985 42.999977ZM 38.999981 42.999977L 50.999973 42.999977M 38.999981 46.999977L 32.999985 46.999977M 36.999981 56.999969L 41.25198 51.685974M 34.999985 32.999985L 40.263981 39.315979M 50.999973 46.999977L 56.999969 46.999977M 52.999973 56.999969L 48.747974 51.685974M 54.999969 32.999985L 49.735973 39.315979"></path></g></g></g><g id="g-root-tx_breaking_m8lafmddkdty-stroke" data-item-order="1000000000" transform="translate(572, 134)"></g><g id="g-root-tx_addednew_8z07bmddj08y-stroke" data-item-order="1000000000" transform="translate(200, 170)"></g><g id="g-root-tx_100_dcya6qddkemn-stroke" data-item-order="1000000000" transform="translate(80, 374)"></g><g id="g-root-ic_new_58mc2ddhlvr-stroke" data-item-order="1000000000" transform="translate(266.1310119628906, 386)"><g id="ic_new_58mc2ddhlvr-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#43dd93" stroke-width="2"><g><path d="M 10.999999 17.999994L 56.999969 17.999994M 10.999999 49.999973L 56.999969 49.999973M 20.957993 39.999981L 20.957993 27.999989L 26.957989 39.999981L 26.957989 27.999989M 36.999981 39.999981L 32.999985 39.999981C 31.895414 39.999981 30.999987 39.104549 30.999987 37.999981L 30.999987 29.999987C 30.999987 28.895418 31.895414 27.999989 32.999985 27.999989L 36.999981 27.999989M 30.999987 33.999985L 34.999985 33.999985M 48.957973 27.999989L 48.957973 31.527987C 48.957302 34.468868 48.272594 37.369286 46.957977 39.999981L 44.957977 31.999985L 42.957977 39.999981C 41.642456 37.369614 40.957699 34.468979 40.957981 31.527987L 40.957981 27.999989"></path></g></g></g><g id="g-root-tx_111_vccgsyddkef5-stroke" data-item-order="1000000000" transform="translate(440, 374)"></g><g id="g-root-ic_aler_3d72qddj11n-stroke" data-item-order="1000000000" transform="translate(626.1309814453125, 386)"><g id="ic_aler_3d72qddj11n-stroke" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="4" stroke="#fb6762" stroke-width="2"><g><path d="M 44.875999 51.492001L 44.875999 51.492001M 44.875999 46.992001L 44.875999 40.992001M 46.551998 34.992001C 46.221634 34.373352 45.577335 33.987 44.875999 33.987C 44.174667 33.987 43.530365 34.373352 43.200001 34.992001L 33.087997 54.268002C 32.784126 54.845463 32.807697 55.540451 33.150002 56.096001C 33.49646 56.654095 34.107109 56.993095 34.764 56.992001L 54.987999 56.992001C 55.64489 56.993095 56.255539 56.654095 56.602001 56.096001C 56.944302 55.540451 56.967873 54.845463 56.663998 54.268002ZM 31.124001 45L 15.124001 45C 12.914861 45 11.124 43.209141 11.124 41L 11.124 15C 11.124 12.790861 12.914861 11 15.124001 11L 45.124001 11C 47.333138 11 49.124001 12.790861 49.124001 15L 49.124001 29M 22.27 21.619999L 17.986 25.987999L 22.27 30.358M 37.251999 21.619999L 41.535999 25.987999L 37.251999 30.358M 27.122 31.450001L 31.492001 21.619999"></path></g></g></g><g id="g-root-tx_initialr_hsrsb6ddkem8-stroke" data-item-order="1000000000" transform="translate(62, 410)"></g><g id="g-root-tx_bugfixin_mgpgk2ddkf7u-stroke" data-item-order="1000000000" transform="translate(416, 410)"></g></g></g><path id="w13ym6fmdnfrwo" d="M65.283 12.757a.35.35 0 0 0 .584.157l5.203-5.141-6.183 3.523.396 1.461zm-2.216-11.7a.35.35 0 0 0-.522.305v3.111l3.276-1.868-2.754-1.548zm3.728 2.105l-4.25 2.421v2.445l6.391-3.644-2.141-1.222zm4.708 3.303a.35.35 0 0 0 0-.609l-1.592-.9-7.365 4.199v1.782a.35.35 0 0 0 .523.305l8.435-4.777z M44.542 2.513c0-.433.355-.783.792-.783s.792.35.792.783-.355.783-.792.783-.792-.35-.792-.783zm59.171 0c0-.433.355-.783.792-.783s.792.35.792.783-.355.783-.792.783-.792-.35-.792-.783zm-85.951 7.636h-1.27v-.487c-.276.201-.864.609-1.881.609-1.202 0-2.274-.794-2.137-2.078.118-1.106 1.153-1.584 1.848-1.727l2.17-.345c0-.539-.29-.956-1.064-1.006s-1.21.305-1.571 1.017l-1.124-.605c1.218-2.631 5.029-1.764 5.029.414v4.207zm-1.27-2.86c.006.396-.062 1.112-.819 1.59-.587.37-1.841.299-1.903-.395-.049-.555.461-.791.906-.898l1.816-.297zm72.662 2.86h-1.27v-.487c-.276.201-.864.609-1.881.609-1.202 0-2.274-.794-2.137-2.078.118-1.106 1.153-1.584 1.848-1.727l2.17-.345c0-.539-.29-.956-1.064-1.006s-1.21.305-1.571 1.017l-1.124-.605c1.218-2.631 5.029-1.764 5.029.414v4.207zm-1.27-2.86c.006.396-.062 1.112-.82 1.59-.587.37-1.841.299-1.903-.395-.049-.555.461-.791.906-.898l1.816-.297zM99.096 10.149H97.85v-8.45h1.246v4.895l2.68-2.559h1.738l-2.633 2.535 2.715 3.578h-1.556l-2.077-2.707-.867.844v1.863zm6.053-6.114h-1.255v6.113h1.255V4.035zm-59.2 0h-1.255v6.113h1.255V4.035zm5.584 6.113V1.697h1.255v2.695c.361-.346 1-.485 1.47-.485 1.452 0 2.477 1.082 2.457 2.448v3.792h-1.27v-3.68c0-.408-.214-1.339-1.315-1.339-.968 0-1.342.756-1.342 1.339v3.681h-1.255zm-4.76-4.894V4.039h.621a.45.45 0 0 0 .45-.45v-.855h1.251v1.305h1.309v1.215h-1.309v3.109c0 .293.105.664.648.664.365 0 .531-.035.736-.07v1.137s-.361.113-.857.113c-1.398 0-1.777-1.051-1.777-1.788V5.254h-1.071zM36.528 4.039h-1.394l2.191 6.106h1.125l1.234-3.918 1.238 3.918h1.129l2.188-6.106h-1.383l-1.359 3.93-1.256-3.93h-1.124l-1.242 3.957-1.348-3.957zM26.212 7.141c-.02 1.566 1.187 3.129 3.223 3.129 1.566 0 2.383-.918 2.734-1.719L31.172 8c-.315.399-.801 1.094-1.738 1.094-1.145 0-1.825-.781-1.891-1.52h4.625c.074-.284.148-.995-.03-1.559-.336-1.064-1.221-2.102-2.839-2.102s-3.088 1.152-3.088 3.227zm1.363-.75h3.348c-.055-.43-.566-1.301-1.623-1.301a1.79 1.79 0 0 0-1.725 1.301zm-8.758.75c.038 1.758 1.277 3.133 3.145 3.133 1.074 0 1.723-.477 1.961-.672v.547h1.242V1.703h-1.258v2.888c-.414-.36-1.062-.68-1.93-.68-1.91 0-3.198 1.473-3.16 3.23zm1.309-.08c0 1.119.723 1.978 1.836 1.978a1.88 1.88 0 0 0 1.94-1.904c0-1.371-1.011-1.99-1.972-1.99s-1.805.798-1.805 1.916zm76.683-.028C96.771 5.275 95.532 3.9 93.664 3.9c-1.074 0-1.723.477-1.961.672v-.547h-1.242v8.22h1.258V9.583c.414.36 1.063.68 1.93.68 1.91 0 3.198-1.473 3.16-3.23zm-1.309.08c0-1.119-.723-1.978-1.836-1.978a1.88 1.88 0 0 0-1.94 1.904c0 1.371 1.011 1.99 1.972 1.99S95.5 8.231 95.5 7.113zM106.441 10.173V4.036h1.254v.382c.361-.346 1-.485 1.47-.485 1.452 0 2.477 1.082 2.457 2.448v3.792h-1.27V6.492c0-.408-.214-1.339-1.315-1.339-.969 0-1.342.756-1.342 1.339v3.681h-1.254zm-30.383-.021V1.824h1.084l4.215 5.777V1.824h1.32v8.328h-1.094l-4.207-5.796v5.796h-1.319zM5.24 10.149H4V2.377h1.014l2.664 3.597 2.654-3.592h1.03v7.766h-1.256V4.762L7.678 8.068 5.24 4.742v5.407z" transform="translate(654, 475)" fill="#ababab88" stroke="none"></path></svg>
package/lib/app.js ADDED
@@ -0,0 +1,48 @@
1
+ const { getParametersInput } = require("./input");
2
+ const { getMaxPages, getCommits } = require("./commits");
3
+ const { clean, setPercentage } = require("./screen");
4
+ const { saveJSON } = require("./output");
5
+
6
+ async function main() {
7
+ const input = getParametersInput();
8
+ const token = input.tk;
9
+ const repo = input.rp;
10
+ const branch = input.branch;
11
+
12
+ const maxPage = await getMaxPages(repo, token, branch);
13
+
14
+ let page = maxPage;
15
+ let version = { major: 1, minor: 0, patch: 0 };
16
+ let blocks = [];
17
+ while (page > 0) {
18
+ blocks.push(getCommits(repo, token, branch, page));
19
+ setPercentage(page, maxPage);
20
+ if (blocks.length === 20) {
21
+ version = await getVersionBlock(blocks, version);
22
+ blocks = [];
23
+ }
24
+ page--;
25
+ }
26
+ if (blocks.length > 0) {
27
+ version = await getVersionBlock(blocks, version);
28
+ }
29
+ clean();
30
+ console.log(version);
31
+ saveJSON(input.outputPath, version);
32
+ }
33
+
34
+ async function getVersionBlock(blocks,version) {
35
+ const resultVersion = await Promise.all(blocks);
36
+ const existsVersion = resultVersion.reduce((acc, obj) => {
37
+ Object.keys(obj).forEach(key => acc[key] = (acc[key] || 0) + obj[key]);
38
+ return acc;
39
+ }, {});
40
+ if (existsVersion) {
41
+ version.major = version.major + existsVersion.major;
42
+ version.minor = version.minor + existsVersion.minor;
43
+ version.patch = version.patch + existsVersion.patch;
44
+ }
45
+ return version;
46
+ }
47
+
48
+ exports.main = main;
package/lib/commits.js ADDED
@@ -0,0 +1,70 @@
1
+ const { executeRequest } = require("./request");
2
+ const { generateSemanticVersion } = require("./semantic");
3
+
4
+ function getOptions(repo, token, branch, page) {
5
+ const bch = branch ? `&sha=${branch}` : '';
6
+ return {
7
+ hostname: "api.github.com",
8
+ port: 443,
9
+ path: `/repos/${repo}/commits?${page ? 'page=' + page : ''}&per_page=100${bch}`,
10
+ headers: {
11
+ "User-Agent": "MeuApp/1.0.0",
12
+ "Authorization": "Bearer " + token
13
+ },
14
+ };
15
+ }
16
+
17
+ const getMaxPages = (repo, token, branch) => {
18
+ return executeRequest(getOptions(repo, token, branch), (res, resolve, reject) => {
19
+ try {
20
+ const linkHeader = res.headers.link;
21
+ if (!linkHeader) {
22
+ console.log("Nenhuma paginação encontrada. Apenas uma página disponível.");
23
+ return;
24
+ }
25
+ const match = linkHeader.match(/&page=(\d+)>; rel="last"/);
26
+ const totalPages = match ? parseInt(match[1], 10) : 1;
27
+ resolve(totalPages);
28
+ } catch (e) {
29
+ resolve(1);
30
+ }
31
+ });
32
+ }
33
+
34
+ const getCommits = (repo, token, branch, page) => {
35
+ return executeRequest(getOptions(repo, token, branch, page), (res, resolve, reject) => {
36
+ const statusCode = res.statusCode;
37
+ const body = [];
38
+ res.on("data", (chunk) => {
39
+ body.push(chunk);
40
+ });
41
+ res.on("end", () => {
42
+ const commits = JSON.parse(Buffer.concat(body));
43
+ if (statusCode !== 200) {
44
+ console.log(`status code: ${statusCode}`);
45
+ console.log(commits);
46
+ return;
47
+ }
48
+ let major = 0;
49
+ let minor = 0;
50
+ let patch = 0;
51
+ if (commits.length > 0) {
52
+ let idxCommit = commits.length - 1;
53
+ while (idxCommit > 0) {
54
+ const version = generateSemanticVersion(commits[idxCommit].commit, major, minor, patch);
55
+ if (version) {
56
+ major = version.major;
57
+ minor = version.minor;
58
+ patch = version.patch;
59
+ }
60
+ idxCommit--;
61
+ }
62
+ resolve({ major, minor, patch });
63
+ } else {
64
+ resolve(null);
65
+ }
66
+ });
67
+ });
68
+ }
69
+
70
+ module.exports = { getMaxPages, getCommits };
package/lib/input.js ADDED
@@ -0,0 +1,55 @@
1
+ const { exit } = require("./screen");
2
+
3
+ const getParametersInput = () => {
4
+ const args = process.argv.slice(2);
5
+ let outputPath = "version.json";
6
+ let tk = undefined;
7
+ let rp = undefined;
8
+ let branch = undefined;
9
+
10
+ for (let i = 0; i < args.length; i++) {
11
+ switch (args[i]) {
12
+ case "-o":
13
+ outputPath = args[i + 1] || outputPath;
14
+ i++;
15
+ break;
16
+ case "-t":
17
+ tk = args[i + 1] || tk;
18
+ i++;
19
+ break;
20
+ case "-r":
21
+ rp = args[i + 1] || rp;
22
+ i++;
23
+ break;
24
+ case "-b":
25
+ branch = args[i + 1] || branch;
26
+ i++;
27
+ break;
28
+ case "-help":
29
+ showHelp();
30
+ break;
31
+ }
32
+ }
33
+ if (!tk || !rp) {
34
+ showHelp();
35
+ }
36
+ return {
37
+ outputPath,
38
+ tk,
39
+ rp,
40
+ branch,
41
+ }
42
+ };
43
+
44
+ function showHelp() {
45
+ console.log(`Version-Commit
46
+ Opções:
47
+ -o <path> Output file path (e.g., ./src/assets/version.json)
48
+ -t <token> Token used in the operation
49
+ -r <repository> Repository in the format user/repo (e.g., danilo/servidorliso)
50
+ -help Displays this help message
51
+ `);
52
+ exit();
53
+ }
54
+
55
+ module.exports = { getParametersInput };
package/lib/output.js ADDED
@@ -0,0 +1,7 @@
1
+ const fs = require('node:fs');
2
+
3
+ function saveJSON(path, content) {
4
+ fs.writeFileSync(path, JSON.stringify(content));
5
+ }
6
+
7
+ module.exports = { saveJSON };
package/lib/request.js ADDED
@@ -0,0 +1,14 @@
1
+ const https = require("https");
2
+
3
+ const executeRequest = (options, f) => {
4
+ return new Promise(function (myResolve, myReject) {
5
+ try {
6
+ const req = https.request(options,(res) => f(res,myResolve, myReject));
7
+ req.end();
8
+ } catch (e) {
9
+ myReject(e);
10
+ }
11
+ });
12
+ }
13
+
14
+ module.exports = { executeRequest };
package/lib/screen.js ADDED
@@ -0,0 +1,14 @@
1
+ const setPercentage = (value, max) => {
2
+ let percentual = Math.round(((max - value) / max) * 100);
3
+ process.stdout.write(`\rProgress: ${percentual}%`);
4
+ }
5
+
6
+ const exit = () => {
7
+ process.exit(0);
8
+ }
9
+
10
+ const clean = () => {
11
+ process.stdout.write("\r" + " ".repeat(50) + "\r");
12
+ }
13
+
14
+ module.exports = { exit, clean, setPercentage };
@@ -0,0 +1,30 @@
1
+
2
+ const generateSemanticVersion = (commit, major, minor, patch) => {
3
+ const prefix = commit.message.split(":")[0].trim();
4
+ const toAddMajor = ['BREAKING CHANGE', '!']
5
+ const toAddPatch = ['fix', 'refactor', 'perf', 'docs', 'style', 'chore'];
6
+ const toAddMinor = ['feat'];
7
+ const toRemovePatch = ['revert'];
8
+ if (exists(toAddMinor, prefix)) {
9
+ minor++;
10
+ patch = 0;
11
+ }
12
+ if (exists(toAddPatch, prefix)) {
13
+ patch++;
14
+ }
15
+ if (exists(toRemovePatch, prefix)) {
16
+ patch++;
17
+ }
18
+ if (exists(toAddMajor, prefix)) {
19
+ major++;
20
+ minor = 0;
21
+ patch = 0;
22
+ }
23
+ return { major, minor, patch };
24
+ }
25
+
26
+ function exists(toList, value) {
27
+ return toList.some(item => value.includes(item));
28
+ }
29
+
30
+ module.exports = { generateSemanticVersion };
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "versioncommit",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "./lib/app.js",
6
+ "scripts": {
7
+ "start": "node app.js"
8
+ },
9
+ "bin": {
10
+ "version-commit": "./bin/executor.js"
11
+ },
12
+ "keywords": [
13
+ "version",
14
+ "commit",
15
+ "semantic",
16
+ "versioning"
17
+ ],
18
+ "preferGlobal": true,
19
+ "author": "Danilo Souza",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/danilosoftwares/versionCommit"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/danilosoftwares/versionCommit/issues"
26
+ },
27
+ "homepage": "https://github.com/danilosoftwares/versionCommit#readme",
28
+ "license": "ISC",
29
+ "dependencies": {
30
+ "axios": "^1.7.9"
31
+ }
32
+ }