Description
If a project version is being bumped after v1.0.0
, options.dryRun === true
, and release notes are being generated from a project CHANGELOG
, the notes
lifecycle does not log the generated release notes.
Instead, an Exception
is thrown because the new project version hasn't been written to the CHANGELOG
, and therefore can not be found within the CHANGELOG
content.
Steps to reproduce
- Run
grease
with options.dryRun === true
in a project versioned after v1.0.0
- See error during
notes
lifecycle
Expected behavior
The notes
lifecycle should not require a version
argument if options.dryRun === true
.
Relevant screenshots
grease
output for @flex-development/[email protected]
![notes-lifecycle-dry-run-version-error](https://user-images.githubusercontent.com/20430108/133633512-7bcd10da-a8d3-485d-8d7e-f65c09a0fe4f.png)
Environment
- Node Version:
v16.6.0
- OS:
macOS v11.3.1
- Package Manager:
[email protected]
- Package version(s):
grease<=1.1.0
Possible solution
If possible, the notes
lifecycle should tap into standard-version
changelog
lifecycle to use its options.dryRun
output.
The changelog
lifecycle could also be re-implemented in grease
, but it may be difficult to keep track of future updates to standard-version
. If it is re-implemented, however, the lifecycle signature could be updated and the return type could be changed to Promise<string>
, where string
is the new CHANGELOG
entry, Promise<void>
:
const Changelog: (
options?: IGreaseOptions,
newVersion?: NullishSemanticVersion
) => Promise<NullishString>
The notes
lifecycle signature could also be updated:
const Notes: (
options?: IGreaseOptions,
changelog?: NullishString,
version?: NullishSemanticVersion
) => Promise<NullishString>
Additional context
Exception
origin in notes
lifecycle
// Search for package version in changelog content
if (!versions.includes(version)) {
const data = { errors: { version }, versions }
const message = `${version} not found in ${options.infile}`
throw new Exception(ExceptionStatusCode.NOT_FOUND, message, data)
}