Skip to main content

Crate monochange_config

Crate monochange_config 

Source
Expand description

§monochange_config

monochange_config parses and validates the inputs that drive planning and release commands.

Reach for this crate when you need to load monochange.toml, resolve package references, or turn .changeset/*.md files into validated change signals for the planner.

§Why use it?

  • centralize config parsing and validation rules in one place
  • resolve package references against discovered workspace packages
  • keep CLI command definitions, version groups, and change files aligned with the planner’s expectations

§Best for

  • validating configuration before handing it to planning code
  • parsing and resolving change files in custom automation
  • keeping package-reference rules consistent across tools

§Public entry points

  • load_workspace_configuration(root) loads and validates monochange.toml
  • load_change_signals(root, changes_dir, packages) parses markdown change files into change signals
  • resolve_package_reference(reference, workspace_root, packages) maps package names, ids, and paths to discovered packages
  • apply_version_groups(packages, configuration) attaches configured version groups to discovered packages

§Responsibilities

  • load monochange.toml
  • validate version groups and CLI commands
  • resolve package references against discovered packages
  • parse change-input files, evidence, release-note type / details fields, changelog paths, changelog format overrides, source-provider config, affected-package policy config, and command release/manifest/policy steps

§Example

use monochange_config::load_workspace_configuration;
use monochange_core::ChangelogFormat;

let root = std::env::temp_dir().join("monochange-config-changelog-format-docs");
let _ = std::fs::remove_dir_all(&root);
std::fs::create_dir_all(root.join("crates/core")).unwrap();
std::fs::write(
    root.join("crates/core/Cargo.toml"),
    "[package]\nname = \"core\"\nversion = \"1.0.0\"\n",
)
.unwrap();
std::fs::write(
    root.join("monochange.toml"),
    r#"
[defaults]
package_type = "cargo"

[defaults.changelog]
path = "{{ path }}/CHANGELOG.md"
format = "keep_a_changelog"

[package.core]
path = "crates/core"
"#,
)
.unwrap();

let configuration = load_workspace_configuration(&root).unwrap();
let package = configuration.package_by_id("core").unwrap();

assert_eq!(configuration.defaults.changelog_format, ChangelogFormat::KeepAChangelog);
assert_eq!(package.changelog.as_ref().unwrap().format, ChangelogFormat::KeepAChangelog);
assert_eq!(package.changelog.as_ref().unwrap().path, std::path::PathBuf::from("crates/core/CHANGELOG.md"));

let _ = std::fs::remove_dir_all(&root);

Modules§

lints
Changeset lint suite for monochange.

Structs§

ChangesetLoadContext
LoadedChangesetFile
LoadedChangesetTarget

Constants§

RESERVED_CLI_COMMAND_NAMES

Functions§

apply_version_groups
Apply configured version groups to discovered packages.
build_changeset_load_context
Build reusable lookup tables for loading many .changeset/*.md files.
config_path
Return the canonical monochange.toml path under root.
load_change_signals
Load change signals from one .changeset/*.md file.
load_changeset_contents_with_context
Parse already-loaded changeset text with the shared lookup context.
load_changeset_file
Load one .changeset/*.md file into the structured changeset model.
load_changeset_file_with_context
Load a changeset file with precomputed package/group indexes.
load_workspace_configuration
Load and fully validate monochange.toml for root.
resolve_package_reference
Resolve a package reference without a pre-built context.
validate_versioned_files_content
Validate that versioned file paths exist on disk, ecosystem-typed files contain a readable version field, and regex patterns match actual file content. Returns a list of non-fatal warnings (e.g. empty glob matches).
validate_workspace
Validate configured changesets and their targets for root.