-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: publish
@wroud/conventional-commits-bump
and `@wroud/convent…
…ional-commits-changelog`
- Loading branch information
Showing
11 changed files
with
233 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
@@ -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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters