Create a Git commit with a simple command and manage the repository version.
You can add this tool to your project by running the following command in your terminal. It will download the necessary scripts.
mkdir -p version && curl -o autocommit.sh https://raw.githubusercontent.com/arielivandiaz/auto-commit/main/autocommit.sh && curl -o version/updateVersion.js https://raw.githubusercontent.com/arielivandiaz/auto-commit/main/version/updateVersion.jsAfter downloading, you need to give the script execution permissions:
chmod +x autocommit.shThe version number is sourced and updated from:
package.json
Version syntax: major.minor.patch (e.g., 0.11.22)
Update Patch Version
(Increments the third number, e.g., 2.0.4 -> 2.0.5)
# Pushes to the current branch
sh autocommit.sh
# Pushes to a specific branch (e.g., develop)
sh autocommit.sh developUpdate Minor Version
(Increments the second number and resets patch to 0, e.g., 2.0.5 -> 2.1.0)
# Pushes to the current branch
sh autocommit.sh v
# Pushes to a specific branch (e.g., develop)
sh autocommit.sh v developUpdate Major Version
(Increments the first number and resets minor and patch to 0, e.g., 2.1.0 -> 3.0.0)
# Pushes to the current branch
sh autocommit.sh mv
# Pushes to a specific branch (e.g., develop)
sh autocommit.sh mv develop- Update Version: The Node.js script (
version/updateVersion.js) readspackage.json, increments the version number based on the command-line argument, and saves the file. - Git Status: Displays the current status of the repository.
- Stage Files: Adds all modified files to the staging area (
git add -A). - Commit: Creates a commit with a message formatted as
v<new_version>(e.g.,v2.0.5). - Push: Pushes the commit to the specified branch (or the current branch if none is provided) on the
originremote.
- Node.js and npm
- A
package.jsonfile with aversionkey in your project root.
Author