changeset_reader.ts

Declarations
#

Changeset parsing and version prediction from .changeset/*.md files.

Reads changesets to determine which packages need publishing and their version bumps. For auto-generating changesets during publishing, see changeset_generator.ts.

7 declarations

view source

ChangesetInfo
#

determine_bump_from_changesets
#

changeset_reader.ts view source

(changesets: ChangesetInfo[], package_name: string): BumpType | null

Determines the bump type for a package from its changesets.

When multiple changesets exist for the same package, returns the highest bump type (major > minor > patch) to ensure the most significant change is reflected in the version bump.

changesets

type ChangesetInfo[]

package_name

type string

returns

BumpType | null

the highest bump type, or null if package has no changesets

has_changesets
#

changeset_reader.ts view source

(repo: LocalRepo): Promise<boolean>

Checks if a repo has any changeset files (excluding README.md).

Used by preflight checks and publishing workflow to determine which packages need to be published. Returns false if .changeset directory doesn't exist or contains only README.md.

repo

returns

Promise<boolean>

true if repo has unpublished changesets

parse_changeset_content
#

changeset_reader.ts view source

(content: string, filename?: string): ChangesetInfo | null

Parses changeset content string from markdown format.

Pure function for testability - no file I/O, just string parsing. Extracts package names, bump types, and summary from YAML frontmatter format. Returns null if format is invalid or no packages found.

Expected format: --- "package-name": patch "@scope/package": minor ---

Summary of changes

content

changeset markdown with YAML frontmatter

type string

filename

optional filename for error reporting context

type string
default 'changeset.md'

returns

ChangesetInfo | null

parsed changeset info or null if invalid format

parse_changeset_file
#

changeset_reader.ts view source

(filepath: string, log?: Logger | undefined): Promise<ChangesetInfo | null>

filepath

type string

log?

type Logger | undefined
optional

returns

Promise<ChangesetInfo | null>

predict_next_version
#

changeset_reader.ts view source

(repo: LocalRepo, log?: Logger | undefined): Promise<{ version: string; bump_type: BumpType; } | null>

Predicts the next version by analyzing all changesets in a repo.

Reads all changesets, determines the highest bump type for the package, and calculates the next version. Returns null if no changesets found.

Critical for dry-run mode accuracy - allows simulating publishes without actually running gro publish which consumes changesets.

repo

log?

type Logger | undefined
optional

returns

Promise<{ version: string; bump_type: BumpType; } | null>

predicted version and bump type, or null if no changesets

read_changesets
#

Depends on
#

Imported by
#