Skip to content

🐛 Can't find package version in CHANGELOG during dry runs #25

@unicornware

Description

@unicornware

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

  1. Run grease with options.dryRun === true in a project versioned after v1.0.0
  2. 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

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)
  }

Metadata

Metadata

Assignees

Labels

status:wipwork in progresstype:fixbug reports and fixes

Type

No type

Projects

Status

📋 Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions