Skip to content

Commit

Permalink
chore: publish @wroud/conventional-commits-bump and `@wroud/convent…
Browse files Browse the repository at this point in the history
…ional-commits-changelog`
  • Loading branch information
Wroud committed Oct 7, 2024
1 parent b8957d3 commit 719532f
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 16 deletions.
21 changes: 21 additions & 0 deletions packages/conventional-commits-bump/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Aleksei Potsetsuev (Wroud)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
62 changes: 62 additions & 0 deletions packages/conventional-commits-bump/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# @wroud/conventional-commits-bump

[![ESM-only package][package]][esm-info-url]
[![NPM version][npm]][npm-url]

<!-- [![Install size][size]][size-url] -->

[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
[esm-info-url]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://img.shields.io/npm/v/@wroud/conventional-commits-bump.svg
[npm-url]: https://npmjs.com/package/@wroud/conventional-commits-bump
[size]: https://packagephobia.com/badge?p=@wroud/conventional-commits-bump
[size-url]: https://packagephobia.com/result?p=@wroud/conventional-commits-bump

`@wroud/conventional-commits-bump` is a utility designed to determine the appropriate version bump type based on conventional commits. This library helps automate the versioning process by analyzing commit messages and categorizing them as major, minor, or patch updates.

## Features

- **Version Bumping Logic**: Automatically determines the version bump type ("major", "minor", or "patch") based on commit types and breaking changes.
- **TypeScript Support**: Written in TypeScript for enhanced type safety and modern JavaScript features.
- [Pure ESM package][esm-info-url]

## Installation

Install via npm:

```sh
npm install @wroud/conventional-commits-bump @wroud/conventional-commits-parser
```

## Usage

Use the `getConventionalCommitsBump` function to analyze an array of conventional commits and determine the appropriate version bump:

```ts
import type { IConventionalCommit } from "@wroud/conventional-commits-parser";
import { getConventionalCommitsBump } from "@wroud/conventional-commits-bump";

const commits: IConventionalCommit[] = [
{ type: "feat", breakingChanges: [] },
{ type: "fix", breakingChanges: [] },
];

const bump = getConventionalCommitsBump(commits);
console.log(bump); // Output: "minor"
```

## How does this relate to SemVer?

- `fix` type commits should be translated to **PATCH** releases.
- `feat` type commits should be translated to **MINOR** releases.
- Commits with **BREAKING CHANGE** in the commit messages, regardless of type, should be translated to **MAJOR** releases.

In this example, if any commit includes breaking changes, the bump will be "major". If there are no breaking changes but a commit of type "feat" is present, it will result in a "minor" bump; otherwise, it will return "patch" if there are any "fix" commits.

## Changelog

All notable changes to this project will be documented in the [CHANGELOG](./CHANGELOG.md) file.

## License

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
20 changes: 18 additions & 2 deletions packages/conventional-commits-bump/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"name": "@wroud/conventional-commits-bump",
"description": "A utility for determining version bump types (major, minor, patch) based on conventional commit messages, facilitating semantic versioning in your projects.",
"version": "0.0.1",
"private": true,
"type": "module",
"packageManager": "[email protected]",
"bin": "./lib/cli.js",
"exports": {
".": "./lib/index.js"
},
"scripts": {
"ci:release": "yarn ci release --prefix cc-bump-v",
"ci:git-tag": "yarn ci git-tag --prefix cc-bump-v",
"ci:release-github": "yarn ci release-github --prefix cc-bump-v",
"test": "tests-runner",
"test:ci": "CI=true yarn run test",
"build": "tsc -b",
Expand All @@ -23,11 +26,24 @@
"@tsconfig/node20": "^20",
"@types/node": "^20",
"@vitest/coverage-v8": "^2",
"@wroud/ci": "workspace:*",
"@wroud/tests-runner": "workspace:*",
"@wroud/tsconfig": "workspace:*",
"concurrently": "^8",
"rimraf": "^6",
"typescript": "^5",
"vitest": "^2"
}
},
"keywords": [
"semantic-versioning",
"semver",
"conventional-commits",
"version-bump",
"npm",
"typescript",
"automated-versioning",
"release-management",
"commit-parser",
"javascript"
]
}
21 changes: 21 additions & 0 deletions packages/conventional-commits-changelog/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Aleksei Potsetsuev (Wroud)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
80 changes: 80 additions & 0 deletions packages/conventional-commits-changelog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# @wroud/conventional-commits-changelog

[![ESM-only package][package]][esm-info-url]
[![NPM version][npm]][npm-url]

<!-- [![Install size][size]][size-url] -->

[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
[esm-info-url]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://img.shields.io/npm/v/@wroud/conventional-commits-changelog.svg
[npm-url]: https://npmjs.com/package/@wroud/conventional-commits-changelog
[size]: https://packagephobia.com/badge?p=@wroud/conventional-commits-changelog
[size-url]: https://packagephobia.com/result?p=@wroud/conventional-commits-changelog

`@wroud/conventional-commits-changelog` is a TypeScript library designed to generate changelogs in markdown format based on conventional commit messages. It provides a structured and consistent format for documenting changes, helping developers keep track of notable updates and modifications in their projects.

## Features

- **Changelog Generation**: Automatically create changelogs from conventional commits.
- **Customizable Headers**: Generate changelog headers with options for headline levels and descriptions.
- **Structured Output**: Organize changelog entries by categories such as features, fixes, breaking changes, and contributors.
- **TypeScript Support**: Written in TypeScript for type safety and improved developer experience.
- [Pure ESM package][esm-info-url]

## Installation

Install via npm:

```sh
npm install @wroud/conventional-commits-changelog @wroud/conventional-commits-parser
```

## Usage

To generate a changelog, you first need to parse your conventional commit messages. Here's an example of how to use the library:

```ts
import {
createConventionalChangelog,
createConventionalChangelogHeader,
} from "@wroud/conventional-commits-changelog";
import { getGitCommits } from "@wroud/git";

async function generateChangelog(version: string, compareUrl?: string) {
const commitGenerator = getGitCommits();
const commits: any[] = []; // Adjust type as needed

for await (const commitInfo of commitGenerator) {
commits.push(commitInfo);
}

const header = createConventionalChangelogHeader(version, compareUrl);
const changelog = createConventionalChangelog(commits);

// Combine header and changelog output
const output: string[] = [];
for (const line of header) {
output.push(line);
}
for await (const line of changelog) {
output.push(line);
}

console.log(output.join("\n"));
}

// Example usage
generateChangelog(
"1.0.0",
"https://github.com/Wroud/foundation/compare/git-v0.1.1...git-v0.1.2",
);
```

## Changelog

All notable changes to this project will be documented in the [CHANGELOG](./CHANGELOG.md) file.

## License

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
19 changes: 17 additions & 2 deletions packages/conventional-commits-changelog/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "@wroud/conventional-commits-changelog",
"private": true,
"description": "A TypeScript library for generating markdown changelogs from conventional commit messages, providing a structured and consistent format for documenting project updates.",
"version": "0.0.1",
"type": "module",
"packageManager": "[email protected]",
"exports": {
".": "./lib/index.js"
},
"scripts": {
"ci:release": "yarn ci release --prefix cc-changelog-v",
"ci:git-tag": "yarn ci git-tag --prefix cc-changelog-v",
"ci:release-github": "yarn ci release-github --prefix cc-changelog-v",
"test": "tests-runner",
"test:ci": "CI=true yarn run test",
"build": "tsc -b",
Expand All @@ -22,11 +25,23 @@
"@tsconfig/node20": "^20",
"@types/node": "^20",
"@vitest/coverage-v8": "^2",
"@wroud/ci": "workspace:*",
"@wroud/tests-runner": "workspace:*",
"@wroud/tsconfig": "workspace:*",
"concurrently": "^8",
"rimraf": "^6",
"typescript": "^5",
"vitest": "^2"
}
},
"keywords": [
"changelog",
"markdown",
"conventional-commits",
"typescript",
"git",
"versioning",
"release-notes",
"documentation",
"semantic-versioning"
]
}
6 changes: 3 additions & 3 deletions packages/conventional-commits-parser/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# @wroud/conventional-commits-parser

[![ESM-only package][package]][package-url]
[![ESM-only package][package]][esm-info-url]
[![NPM version][npm]][npm-url]

<!-- [![Install size][size]][size-url] -->

[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
[package-url]: https://npmjs.com/package/@wroud/conventional-commits-parser
[esm-info-url]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://img.shields.io/npm/v/@wroud/conventional-commits-parser.svg
[npm-url]: https://npmjs.com/package/@wroud/conventional-commits-parser
[size]: https://packagephobia.com/badge?p=@wroud/conventional-commits-parser
Expand All @@ -18,7 +18,7 @@

- **Conventional Commits Parsing**: Extract commit types, scopes, and messages.
- **TypeScript**: Written in TypeScript for type safety and modern JavaScript support.
- **ESM Package**: Pure ESM package for modern JavaScript environments.
- [Pure ESM package][esm-info-url]

## Installation

Expand Down
6 changes: 3 additions & 3 deletions packages/di/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# @wroud/di

[![ESM-only package][package]][package-url]
[![ESM-only package][package]][esm-info-url]
[![NPM version][npm]][npm-url]

<!-- [![Install size][size]][size-url] -->

[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
[package-url]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esm-info-url]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://img.shields.io/npm/v/@wroud/di.svg
[npm-url]: https://npmjs.com/package/@wroud/di
[size]: https://packagephobia.com/badge?p=@wroud/di
Expand All @@ -19,7 +19,7 @@
- **Modern JavaScript**: Leverages ES modules, decorators, and asynchronous service loading for advanced performance optimizations.
- **TypeScript**: Written in TypeScript for type safety.
- **Flexible DI**: Supports singleton, transient, and scoped services.
- [Pure ESM package][package-url]
- [Pure ESM package][esm-info-url]

## Installation

Expand Down
6 changes: 3 additions & 3 deletions packages/git/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# @wroud/git

[![ESM-only package][package]][package-url]
[![ESM-only package][package]][esm-info-url]
[![NPM version][npm]][npm-url]

<!-- [![Install size][size]][size-url] -->

[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
[package-url]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esm-info-url]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://img.shields.io/npm/v/@wroud/git.svg
[npm-url]: https://npmjs.com/package/@wroud/git
[size]: https://packagephobia.com/badge?p=@wroud/git
Expand All @@ -20,7 +20,7 @@

- **getGitLastSemverTag**: Returns the most recent semantic version tag from the git history. By default, it checks up to `HEAD` and looks for tags with a `v` prefix, although both can be customized through the `to` and `prefix` parameters.

- [Pure ESM package][package-url]
- [Pure ESM package][esm-info-url]

## Installation

Expand Down
6 changes: 3 additions & 3 deletions packages/github/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# @wroud/github

[![ESM-only package][package]][package-url]
[![ESM-only package][package]][esm-info-url]
[![NPM version][npm]][npm-url]

<!-- [![Install size][size]][size-url] -->

[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
[package-url]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esm-info-url]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[npm]: https://img.shields.io/npm/v/@wroud/github.svg
[npm-url]: https://npmjs.com/package/@wroud/github
[size]: https://packagephobia.com/badge?p=@wroud/github
Expand All @@ -21,7 +21,7 @@ This library uses the `IGitCommitInfo` interface from [`@wroud/git`](https://npm
- **GitHub metadata**: Extract co-authors, GitHub issue links, and commit references from git commits.
- **TypeScript**: Written in TypeScript for type safety and modern JavaScript support.
- **GitHub URL generation**: Easily generate URLs for issues and commits.
- [Pure ESM package][package-url]
- [Pure ESM package][esm-info-url]

## Installation

Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3291,6 +3291,7 @@ __metadata:
"@tsconfig/node20": "npm:^20"
"@types/node": "npm:^20"
"@vitest/coverage-v8": "npm:^2"
"@wroud/ci": "workspace:*"
"@wroud/conventional-commits-parser": "workspace:^0"
"@wroud/tests-runner": "workspace:*"
"@wroud/tsconfig": "workspace:*"
Expand All @@ -3310,6 +3311,7 @@ __metadata:
"@tsconfig/node20": "npm:^20"
"@types/node": "npm:^20"
"@vitest/coverage-v8": "npm:^2"
"@wroud/ci": "workspace:*"
"@wroud/conventional-commits-parser": "workspace:^0"
"@wroud/tests-runner": "workspace:*"
"@wroud/tsconfig": "workspace:*"
Expand Down

0 comments on commit 719532f

Please sign in to comment.