From a8aeb1cfea82a5c3467fe2194ec344537d979f49 Mon Sep 17 00:00:00 2001 From: Patrick Ruhkopf Date: Fri, 16 Feb 2024 17:17:25 -0500 Subject: [PATCH] fix: missing version in changelog file --- .../filter-by-workspace-path/CHANGELOG.md | 37 +++++++++---------- packages/filter-by-workspace-path/README.md | 1 - .../filter-by-workspace-path/src/index.ts | 14 ++++++- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/packages/filter-by-workspace-path/CHANGELOG.md b/packages/filter-by-workspace-path/CHANGELOG.md index c232a57..2190939 100644 --- a/packages/filter-by-workspace-path/CHANGELOG.md +++ b/packages/filter-by-workspace-path/CHANGELOG.md @@ -1,18 +1,28 @@ -# (Tue Feb 13 2024) +# v0.1.0 (Fri Feb 16 2024) +#### 🚀 Enhancement + +- feat: omit commits that aren't related to a pull request [#9](https://github.com/restfulhead/npm-auto-plugins/pull/9) ([@restfulhead](https://github.com/restfulhead)) + +#### 📝 Documentation + +- doc: provide more details about the merge commit issue [#8](https://github.com/restfulhead/npm-auto-plugins/pull/8) ([@restfulhead](https://github.com/restfulhead)) +#### Authors: 1 + +- Patrick Ruhkopf ([@restfulhead](https://github.com/restfulhead)) --- -# (Tue Feb 13 2024) +# v0.0.1 (Fri Feb 16 2024) -#### 🚀 Enhancement +#### 🐛 Patch -- chore: fix release [#30](https://github.com/restfulhead/npm-auto-plugins/pull/30) ([@restfulhead](https://github.com/restfulhead)) +- fix: filter out commits in other ws dir with the same prefix [#5](https://github.com/restfulhead/npm-auto-plugins/pull/5) ([@restfulhead](https://github.com/restfulhead)) #### 🔩 Internal -- chore: prepare release [#32](https://github.com/restfulhead/npm-auto-plugins/pull/32) ([@restfulhead](https://github.com/restfulhead)) +- chore: prepare release [#6](https://github.com/restfulhead/npm-auto-plugins/pull/6) ([@restfulhead](https://github.com/restfulhead)) #### Authors: 1 @@ -20,23 +30,12 @@ --- -# (Mon Feb 12 2024) - -#### 🚀 Enhancement - -- fix: workflow and release [#25](https://github.com/restfulhead/npm-auto-plugins/pull/25) ([@restfulhead](https://github.com/restfulhead)) -- fix: cleanup [#23](https://github.com/restfulhead/npm-auto-plugins/pull/23) ([@restfulhead](https://github.com/restfulhead)) - -#### 🐛 Patch - -- fix: test and release workflow [#28](https://github.com/restfulhead/npm-auto-plugins/pull/28) ([@restfulhead](https://github.com/restfulhead)) -- fix: hooks [#21](https://github.com/restfulhead/npm-auto-plugins/pull/21) ([@restfulhead](https://github.com/restfulhead)) +# v0.0.1 (Tue Feb 13 2024) #### 🔩 Internal -- chore: prepare release [#29](https://github.com/restfulhead/npm-auto-plugins/pull/29) ([@restfulhead](https://github.com/restfulhead)) -- chore: prepare release [#27](https://github.com/restfulhead/npm-auto-plugins/pull/27) ([@restfulhead](https://github.com/restfulhead)) -- chore: prepare release [#24](https://github.com/restfulhead/npm-auto-plugins/pull/24) ([@restfulhead](https://github.com/restfulhead)) +- chore: prepare release [#4](https://github.com/restfulhead/npm-auto-plugins/pull/4) ([@restfulhead](https://github.com/restfulhead)) +- refactor: renamed to follow auto's naming convention [#3](https://github.com/restfulhead/npm-auto-plugins/pull/3) ([@restfulhead](https://github.com/restfulhead)) #### Authors: 1 diff --git a/packages/filter-by-workspace-path/README.md b/packages/filter-by-workspace-path/README.md index 7d28cba..230d55c 100644 --- a/packages/filter-by-workspace-path/README.md +++ b/packages/filter-by-workspace-path/README.md @@ -30,7 +30,6 @@ However, carefully read the following caveats section. * have `[skip ci]` in their commit message * This plugin modifies the behavior of `auto version`. By default, it seems to set the version to `patch` instead of `noVersion` even if all commits were omitted. With this plugin, `noVersion` is returned if there are no relevant commits. -* While the title in the GitHub release notes is correct, the version is missing in the `CHANGELOG.md` file for currently unknown reasons * You can't use the `shipit` command, because for example, the version in each package should only contain the version number (e.g. `v1.0.0`), but the tag and Github release must include the package name to avoid ambigious release names/tags. Maybe this customization can be added to the plugin in future. (Contributions welcome!) diff --git a/packages/filter-by-workspace-path/src/index.ts b/packages/filter-by-workspace-path/src/index.ts index f8bfb3c..a6a6fd0 100644 --- a/packages/filter-by-workspace-path/src/index.ts +++ b/packages/filter-by-workspace-path/src/index.ts @@ -1,6 +1,7 @@ import { execSync } from 'child_process' import * as path from 'path' -import { Auto, IExtendedCommit, ILogger, IPlugin, SEMVER } from '@auto-it/core' +import { Auto, IExtendedCommit, ILogger, IPlugin, SEMVER, inFolder } from '@auto-it/core' +import { inc, ReleaseType } from 'semver' function shouldOmitCommit(currentDir: string, currentWorkspace: string, commit: IExtendedCommit, logger: ILogger): boolean { if (!commit.pullRequest) { @@ -11,7 +12,8 @@ function shouldOmitCommit(currentDir: string, currentWorkspace: string, commit: const fixedFiles = commit.files.map((file) => path.relative(currentDir, file)) const wsDir = path.join(currentWorkspace, path.sep) - const atLeastOneFileInCurrentDir = fixedFiles.find((file) => file.startsWith(wsDir)) + const atLeastOneFileInCurrentDir = fixedFiles.find((file) => inFolder(wsDir, file)) + if (!atLeastOneFileInCurrentDir) { logger.verbose.log(`All files are outside the current workspace directory ('${wsDir}'). Omitting commit '${commit.hash}'.`) return true @@ -53,6 +55,14 @@ export default class FilterByWorkspacePathPlugin implements IPlugin { } return origGetVersion(from, to) } + + release.calcNextVersion = async (lastTag: string) => { + const bump = await release.getSemverBump(lastTag) + const matches = lastTag.match(/(\d+\.\d+\.\d+)/) + const lastVersion = matches ? matches[0] : lastTag + + return inc(lastVersion, bump as ReleaseType) + } }) } }