Skip to content

Commit

Permalink
feat: actualizar readmemd (#62)
Browse files Browse the repository at this point in the history
* feat(internal/docs): Create utils.go and md_docs.go files for documentation purposes

* refactor(go.sum): Update go module dependencies

* feat(cmd): Add generate documentation flag and hide it by default in cmd/root.go

- Modified the root command to include a flag for generating project documentation
- Hidden the 'gen-docs' flag using Flags().MarkHidden() method

This commit adds a new option to the root command, allowing users to generate the documentation for their project with a hidden flag set by default. The changes made are in the cmd/root.go file.

* refactor(internal/pkg/cmd): Move and reorganize command files and modules

* build(Makefile): Update Makefile - Add generate docs task and clean up instructions

* feat(cmd/gen-docs/main.go): Initialize documentation generator

* docs(README.md): Update project documentation

- Clarify installation instructions
- Include development and release information
- Add hooks section
- Improve license explanation
- Create README.md.template for future updates

* refactor(cmd/gommitizen/main.go): Modify import path for cmd package

- Replace internal/cmd import with internal/pkg/cmd
- Update the execution of root command accordingly

* docs(pkg/docs): Move gen-docs files to pkg/docs directory, create new empty files in pkg/docs for potential future content

* docs(CHANGELOG.md): Consolidate version management

* docs(pkg/docs): Refactor generateCommandDocumentation function

- Separated the function to handle command flags and subcommands for better readability
- Modified the function to return a CmdData struct containing all necessary command details (name, long description, short description, usage, example, flags, and subcommands)
- Added comments for improved understanding of the code
- Improved the handling of hidden flags and invalid commands
- Sorted the subcommands by name before appending them to the CmdData struct

* docs(cmd/gen-docs/main.go): Update markdown generation process to use new template and log errors using slog package

* refactor(README.md): Update hooks description, change shell commands to getCommands

- Description of hooks now explains they are getCommands (not shell commands)
- All hooks fields are optional

This commit updates the README file to clarify that the hooks described in the file are GetCommands and not shell commands. Additionally, it highlights that all hooks fields are optional.

* chore: Update documentation (README.md)

- Clarify the purpose of the project
- Explain how to use the tool
- Provide information on development and hooks
- Improve the organization and readability of the document

- Add a brief introduction
- Detail the installation process
- Describe the command line usage
- Include examples for each hook available
- Update the development section
- Explain how to run the project in different modes (development, release, pipeline)
- Provide instructions on increasing the version manually
- Mention the license information

- Remove unnecessary whitespace and improve formatting
- Fix typos and grammatical errors
- Make the document more accessible and easy to read for a wider audience.

* docs: Update README.md.template

* refactor(md_docs.go): Remove YAML marshalling and log output, simplify template execution

- Eliminate unnecessary YAML data marshalling
- Streamline code by removing debug logging
- Improve readability and maintainability of the function
  • Loading branch information
sergiotejon authored Nov 15, 2024
1 parent c66e9b7 commit d88e4e2
Show file tree
Hide file tree
Showing 27 changed files with 604 additions and 112 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

### Refactor

- cmd flags (#44)
- cmd retrieveCommandFlags (#44)
- **Makefile**: Rearrange build targets, use CURRENT_VERSION for go application
- **internal/config/config.go**: Introduce field filtering in printConfigVersionsPlain function (#42)
- **internal/config/config.go**: Introduce field filtering in printConfigVersionsPlain function (#42)
Expand All @@ -48,13 +48,13 @@

### Refactor

- **.goreleaser.yaml**: Update build process using gommitizen, remove ai-commit, create Docker images and modify build flags
- **.goreleaser.yaml**: Update build process using gommitizen, remove ai-commit, create Docker images and modify build retrieveCommandFlags

## 0.6.2 (2024-10-30)

### Refactor

- **.goreleaser.yaml**: Update GitHub repository owner, set CGO_ENABLED to 0 for all builds, correct version export in gommitizen binary, update Docker image templates and build flags
- **.goreleaser.yaml**: Update GitHub repository owner, set CGO_ENABLED to 0 for all builds, correct version export in gommitizen binary, update Docker image templates and build retrieveCommandFlags

## 0.6.1 (2024-10-30)

Expand Down Expand Up @@ -173,7 +173,7 @@
- add prefix to config (#16)
- add scan target to Makefile to perform a scan with sonnarqube and lint
- **version.go**: add support for manual increment of version
- support for multiples version files Example of usage: file .version.json ``` { "version": "0.12.0", "commit": "37149b77ce36d40422441ad20b999156ba107e18", "version_files": [ "Chart.yaml:version", "other-version.txt:version" ] } ```
- support for multiples version files Example of commandUsage: file .version.json ``` { "version": "0.12.0", "commit": "37149b77ce36d40422441ad20b999156ba107e18", "version_files": [ "Chart.yaml:version", "other-version.txt:version" ] } ```
- add changelog refactor version to use changelog and split update function into two to allow for more flexibility and to allow for the changelog to be updated. Translates comments and literals to english.
- add support of changelog and increment in bump command
- add cobra to handle command input and some extra features like autogenerated help or cli completion
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ release: bump ## Release new version
test-release: ## Test release new version
goreleaser release --snapshot

gen-docs: ## Generate docs
go run cmd/gen-docs/main.go > README.md

clean: ## Clean up
rm -rf ./bin
rm -rf ./dist
165 changes: 97 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Gommitizen

Gommitizen is a command-line tool that helps manage the versioning of a software project. This tool is able to manage serveral projects in a same repository with their different versions each.

The tool analyzes commit messages in a Git repository, looking for certain prefixes in the messages to determine the type of changes made. The prefixes include "BREAKING CHANGE:", "feat:", and "fix:", between others, which likely refer to breaking changes, new features, and bug fixes, respectively.

Version information is stored in a `VersionData` structure, which includes the current version, the current commit, and a list of version files. This information can be used to generate a changelog, determine the next version of the software, or perform other tasks related to version management.
Gommitizen is a command-line tool that helps manage the versioning of a software project. This tool is
able to manage serveral projects in a same repository with their different versions each. It supports the conventional
commits specification (https://www.conventionalcommits.org/en/v1.0.0/) to determine the increment of the version for
each project.

## Installation

Expand Down Expand Up @@ -41,108 +40,138 @@ This will install the binary in the `/usr/local/bin` directory.

## Usage

To use Gommitizen, run:
Next a list of the available commands and their description:
- `bump`: Make a version bump

```bash
gommitizen <command> [flags]
```
- `get`: Give a list of projects, their versions and other information

### Commands
- `init`: Start a repository to use gommitizen

The following commands are available:
### bump command

- `bump`: Bumps the version of a project.
- `completion`: Generates the completion script for the specified shell.
- `help`: Shows the help message.
- `init`: Initializes the versioning of a project.
Increment the version of the project according to the conventional commits specification.

#### Global flags
**Flags:**
- `-c`, `--changelog`: generate the changelog for the newest version

The following flags are available for all commands:
- `-i`, `--increment`: manually specify the desired increment {MAYOR, MINOR, PATCH}

- `-h` or `--help`: Shows the help message.
- `-t` or `--toggle`: Help message for toggle.

#### Init flags

The following flags are available for the `init` command:
**Examples of usage:**

- `-d` or `--directory`: The directory where the project is located. If not specified, the current directory is used.
- `-p` or `--prefix`: The prefix of the tag message. If not specified, an empty prefix is used.
To bump the version of a project, run:
```bash
gommitizen bump
```
This will bump the version of all projects in the current directory.
If you want to bump the version of a specific project, run:
```bash
gommitizen bump -d <directory>
```
This will bump the version of the project in the given directory.
If you want to bump the version of projects and generate a changelog, run:
```bash
gommitizen bump -c
```
This will bump the version of the projects and generate a changelog with the changes made since the last version.
If you want to bump the version of project to a major version, run:
```bash
gommitizen bump -i major
```

#### Bump flags

The following flags are available for the `bump` command:

- `-d` or `--directory`: The directory where the project is located. If not specified, it scans all the directories in the current directory to look for projects with a .version file.
- `-c` or `--changelog`: It generates a changelog with the changes made since the last version.
- `-i` or `--increment`: The type of increment to make. It can be `major`, `minor`, or `patch`. If it is specified the automatic detection of version is not run.

### Docker

To run Gommitizen in a Docker container, run:

```bash
docker run --rm \
-e GIT_USER_NAME=user.name \
-e GIT_USER_EMAIL=user@email \
-v $(pwd):/source \
ghcr.io/freepik-company/gommitizen:<tag> [flags]
```
### get command

Replace `<tag>` with the tag of the image you want to use. Select the command and flags you want to use.
Show information about the projects in the repository. It can show the version, the prefix, the commit
information and all the information saved in the config file.

Example:
```bash
docker run --rm \
-e GIT_USER_NAME=user.name \
-e GIT_USER_EMAIL=user@email \
-v $(pwd):/source \
ghcr.io/freepik-company/gommitizen:latest [flags]
```
**Flags:**
- `-o`, `--output`: Select the output format {json, yaml, plain}

- `-p`, `--prefix`: A prefix to look for a project to show information

### Examples

#### Init

To initialize the versioning of a project, run:
**Examples of usage:**

To show all information in yaml format, run:
```bash
gommitizen init -d <directory> -p <prefix>
gommitizen get all -o yaml
```
To show the version of the projects in plain format, run:
```bash
gommitizen get version -o plain
```
or just:
```bash
gommitizen get version
```

This will create a `.version.json` file in the given directory with the version `0.0.0`.

#### Bump

To bump the version of a project, run:

```bash
gommitizen bump
```
**Subcommands:**

This will bump the version of all projects in the current directory.

If you want to bump the version of a specific project, run:

- `all`: Get all the information of the projects in the repository. It will show the version, the prefix, the commit
information and all the information saved in the config file.

- `commit`: Get the commit information of the projects in the repository.

- `prefix`: Get the prefix of the projects in the repository.

- `version`: Get the version of the projects in the repository. It will show the version of the projects and the prefix.

### init command

Initialize the repository to use gommitizen. It will create a file with the version of the project and
the first commit of the project.

**Flags:**
- `-p`, `--prefix`: Select a prefix for the version file



**Examples of usage:**

To initialize the versioning of a project, run:
```bash
gommitizen bump -d <directory>
gommitizen init -d <directory> -p <prefix>`
```
This will create a .version.json file in the given directory with the version 0.0.0.


This will bump the version of the project in the given directory.

if you want to bump the version of projects and generate a changelog, run:



### Docker

To run Gommitizen in a Docker container, run:

```bash
gommitizen bump -c
docker run --rm \
-e GIT_USER_NAME=user.name \
-e GIT_USER_EMAIL=user@email \
-v $(pwd):/source \
ghcr.io/freepik-company/gommitizen:<tag> [retrieveCommandFlags]
```

This will bump the version of the projects and generate a changelog with the changes made since the last version.

If you want to bump the version of project to a major version, run:
Replace `<tag>` with the tag of the image you want to use. Select the command and retrieveCommandFlags you want to use.

Example:
```bash
gommitizen bump -i major
docker run --rm \
-e GIT_USER_NAME=user.name \
-e GIT_USER_EMAIL=user@email \
-v $(pwd):/source \
ghcr.io/freepik-company/gommitizen:latest [retrieveCommandFlags]
```

## Types of commits
Expand Down Expand Up @@ -180,7 +209,7 @@ The version files are structured as follows:
"other-version.txt:version",
"a-file-that-need-a-regex.txt:^version=([0-9]+\\.[0-9]+\\.[0-9]+)$"
],
"prefix": ""
"prefix": "my_prj"
}
```

Expand Down Expand Up @@ -220,7 +249,7 @@ There are four hooks available:
- `pre-changelog`: Runs before the changelog generation.
- `post-changelog`: Runs after the changelog generation.

The hooks are shell commands that are executed in the root of the project. These are all optional fields.
The hooks are shell getCommands that are executed in the root of the project. These are all optional fields.

## Development

Expand Down
Loading

0 comments on commit d88e4e2

Please sign in to comment.