@bfra.me/semantic-release
Version:
Semantic Release shareable configuration and plugins for bfra.me.
1,770 lines (1,755 loc) • 80.1 kB
TypeScript
import { G as GlobalConfig, D as DefineConfigOptions, P as PluginSpec$1 } from './define-config-DZx0_5qY.js';
import { C as CommitAnalyzerConfig, R as ReleaseNotesGeneratorConfig, a as ChangelogConfig, N as NpmConfig, G as GithubConfig, b as GitConfig } from './release-notes-generator-CZ4Fl9fQ.js';
import { BranchSpec } from 'semantic-release';
import { LiteralUnion } from 'type-fest';
import { z } from 'zod';
export { z } from 'zod';
/**
* Configuration composition utilities for semantic-release.
*
* This module provides utilities for merging, extending, and overriding
* semantic-release configurations, enabling complex configuration scenarios
* where presets need to be combined with custom settings. These utilities
* are essential for creating reusable configuration patterns and combining
* multiple configuration sources.
*
* **Key Features:**
* - Intelligent plugin merging with conflict resolution strategies
* - Branch configuration composition with inheritance support
* - Deep configuration merging with type safety
* - Validation integration with comprehensive error reporting
* - Support for preset composition and customization
*
* **Common Use Cases:**
* - Combining preset configurations with project-specific overrides
* - Creating organization-wide configuration templates
* - Building complex monorepo configurations from smaller pieces
* - Environment-specific configuration variations
*
* @example
* ```typescript
* import { mergeConfigs, extendConfig } from '@bfra.me/semantic-release/composition'
* import { npmPreset, githubPreset } from '@bfra.me/semantic-release/presets'
*
* // Merge multiple presets
* const merged = mergeConfigs(
* npmPreset(),
* githubPreset(),
* { dryRun: true } // Add custom overrides
* )
* ```
*
* @example
* ```typescript
* // Extend a base configuration
* const extended = extendConfig(npmPreset(), {
* plugins: [['@semantic-release/npm', { npmPublish: false }]]
* })
* ```
*
* @example
* ```typescript
* // Advanced composition with strategies
* const composed = mergeConfigsWithOptions([
* baseConfig,
* productionConfig,
* environmentConfig
* ], {
* pluginStrategy: 'append', // Add plugins rather than replacing
* branchStrategy: 'merge', // Merge branch configurations
* validate: true // Validate the result
* })
* ```
*/
/**
* Options for configuration composition operations.
*
* These options control how configurations are merged when conflicts arise,
* allowing fine-grained control over the composition process.
*/
interface CompositionOptions {
/**
* How to handle plugin conflicts when merging configurations.
*
* Determines the strategy used when multiple configurations define plugins:
* - `replace`: Replace existing plugins entirely with new ones
* - `merge`: Intelligently merge plugin configurations (default)
* - `append`: Add new plugins after existing ones
* - `prepend`: Add new plugins before existing ones
*
* @default 'merge'
*
* @example
* ```typescript
* // Replace all existing plugins
* mergeConfigsWithOptions([base, override], {
* pluginStrategy: 'replace'
* })
*
* // Append additional plugins
* mergeConfigsWithOptions([base, additional], {
* pluginStrategy: 'append'
* })
* ```
*/
pluginStrategy?: 'replace' | 'merge' | 'append' | 'prepend';
/**
* How to handle branch configuration conflicts.
*
* Determines the strategy for combining branch configurations:
* - `replace`: Use the new branch configuration entirely
* - `merge`: Merge branch configurations intelligently (default)
*
* @default 'merge'
*
* @example
* ```typescript
* // Replace branch configuration completely
* mergeConfigsWithOptions([base, override], {
* branchStrategy: 'replace'
* })
* ```
*/
branchStrategy?: 'replace' | 'merge';
/**
* Whether to perform deep validation on the result.
*
* When enabled, the composed configuration will be validated against
* semantic-release schemas to ensure correctness.
*
* @default true
*
* @example
* ```typescript
* // Skip validation for performance or dynamic configs
* mergeConfigsWithOptions([config1, config2], {
* validate: false
* })
* ```
*/
validate?: boolean;
}
/**
* Merge multiple semantic-release configurations intelligently.
*
* This function takes multiple configuration objects and merges them together,
* applying intelligent strategies for handling conflicts in plugins, branches,
* and other configuration options. The merge process follows semantic-release
* best practices and maintains type safety throughout.
*
* **Merge Behavior:**
* - Simple properties: Later configurations override earlier ones
* - Plugins: Intelligently merged based on plugin names and configurations
* - Branches: Combined with deduplication and smart conflict resolution
* - Arrays: Merged with deduplication where appropriate
*
* @param config1 - First configuration object (base configuration)
* @param config2 - Second configuration object (override configuration)
* @param restConfigs - Additional configuration objects to merge
* @returns A merged configuration object with combined settings
*
* @example
* ```typescript
* // Basic preset merging
* const base = npmPreset({ branches: ['main'] })
* const custom = {
* dryRun: true,
* repositoryUrl: 'https://github.com/user/repo.git'
* }
* const merged = mergeConfigs(base, custom)
* // Result: npmPreset configuration + dryRun + repositoryUrl
* ```
*
* @example
* ```typescript
* // Multi-preset composition
* const merged = mergeConfigs(
* npmPreset(),
* githubPreset(),
* {
* tagFormat: '${name}@${version}', // Custom tag format
* plugins: [
* ['@semantic-release/changelog', { changelogTitle: '# My Changelog' }]
* ]
* }
* )
* ```
*
* @example
* ```typescript
* // Environment-specific configuration
* const production = mergeConfigs(
* baseConfig,
* { ci: true, dryRun: false },
* productionOnlyPlugins
* )
*
* const development = mergeConfigs(
* baseConfig,
* { ci: false, dryRun: true },
* developmentPlugins
* )
* ```
*/
declare function mergeConfigs(config1: GlobalConfig, config2: GlobalConfig, ...restConfigs: GlobalConfig[]): GlobalConfig;
/**
* Merge multiple semantic-release configurations with advanced options.
*
* Provides fine-grained control over the merging process through composition options,
* allowing customization of how conflicts are resolved and how different configuration
* aspects are combined.
*
* @param configs - Array of configuration objects to merge (must have at least one)
* @param options - Options controlling merge behavior and validation
* @returns A merged configuration object with settings from all inputs
*
* @example
* ```typescript
* // Plugin strategy examples
* const replaced = mergeConfigsWithOptions([base, override], {
* pluginStrategy: 'replace' // Use only override plugins
* })
*
* const appended = mergeConfigsWithOptions([base, additional], {
* pluginStrategy: 'append' // Add additional plugins to base
* })
*
* const prepended = mergeConfigsWithOptions([priority, base], {
* pluginStrategy: 'prepend' // Priority plugins run first
* })
* ```
*
* @example
* ```typescript
* // Complex monorepo configuration
* const monorepoConfig = mergeConfigsWithOptions([
* monorepoPreset(),
* packageSpecificConfig,
* environmentConfig
* ], {
* pluginStrategy: 'merge', // Intelligently combine plugins
* branchStrategy: 'merge', // Merge branch configurations
* validate: true // Ensure result is valid
* })
* ```
*/
declare function mergeConfigsWithOptions(configs: readonly [GlobalConfig, ...GlobalConfig[]], options?: CompositionOptions): GlobalConfig;
/**
* Extend a base configuration with additional options.
*
* This function takes a base configuration and extends it with additional options,
* using the same merging strategies as `mergeConfigs` but with a cleaner API
* for the common case of extending a single base configuration.
*
* @param base - Base configuration to extend
* @param extension - Extension configuration
* @param options - Options controlling merge behavior
* @returns An extended configuration object
*
* @example
* ```typescript
* const base = npmPreset()
* const extended = extendConfig(base, {
* dryRun: true,
* plugins: [['@semantic-release/npm', { npmPublish: false }]]
* })
* ```
*/
declare function extendConfig(base: GlobalConfig, extension: GlobalConfig, options?: CompositionOptions): GlobalConfig;
/**
* Override a base configuration with new options.
*
* This function provides complete replacement semantics, where the override
* configuration completely replaces matching properties in the base configuration.
* This is useful when you need to completely replace certain aspects like plugins.
*
* @param base - Base configuration to override
* @param override - Override configuration
* @param options - Options controlling override behavior
* @returns An overridden configuration object
*
* @example
* ```typescript
* const base = npmPreset()
* const overridden = overrideConfig(base, {
* plugins: [['@semantic-release/git']] // Completely replaces plugins
* })
* ```
*/
declare function overrideConfig(base: GlobalConfig, override: GlobalConfig, options?: Omit<CompositionOptions, 'pluginStrategy' | 'branchStrategy'>): GlobalConfig;
/**
* Configuration factory functions and utilities for semantic-release.
*
* This module provides both the enhanced configuration API and backward-compatible
* defineConfig function for semantic-release configurations with comprehensive
* TypeScript support, runtime validation, and environment-specific optimizations.
*
* @example
* ```typescript
* // Basic configuration
* import { defineConfig } from '@bfra.me/semantic-release'
*
* export default defineConfig({
* branches: ['main'],
* plugins: ['@semantic-release/commit-analyzer', '@semantic-release/npm']
* })
* ```
*
* @example
* ```typescript
* // Advanced configuration with environment detection
* import { defineConfig } from '@bfra.me/semantic-release'
*
* export default defineConfig({
* branches: ['main', { name: 'beta', prerelease: true }],
* plugins: [
* '@semantic-release/commit-analyzer',
* ['@semantic-release/npm', { npmPublish: true }],
* '@semantic-release/github'
* ]
* }, {
* environment: 'production',
* validate: true
* })
* ```
*/
/**
* Define semantic-release global configuration with enhanced validation and features.
*
* This is the main configuration factory function that provides comprehensive
* TypeScript support, runtime validation, environment-specific transformations,
* and improved developer experience for semantic-release configurations.
*
* **Features:**
* - Full TypeScript type safety with IntelliSense support
* - Runtime validation with detailed error messages and suggestions
* - Environment-specific configuration transformations
* - Automatic plugin configuration detection and optimization
* - Comprehensive error handling with actionable feedback
*
* @param config - Semantic-release configuration object with full type safety
* @param options - Configuration options for validation and environment processing
* @returns Enhanced and validated semantic-release configuration
*
* @throws {ValidationError} When configuration validation fails with detailed error information
*
* @example
* ```typescript
* // Basic npm package configuration
* export default defineConfig({
* branches: ['main'],
* plugins: [
* '@semantic-release/commit-analyzer',
* '@semantic-release/release-notes-generator',
* '@semantic-release/npm',
* '@semantic-release/github'
* ]
* })
* ```
*
* @example
* ```typescript
* // Monorepo package configuration
* export default defineConfig({
* tagFormat: '${name}@${version}',
* branches: ['main'],
* plugins: [
* ['@semantic-release/commit-analyzer', {
* preset: 'conventionalcommits'
* }],
* ['@semantic-release/npm', {
* npmPublish: true,
* tarballDir: 'dist'
* }]
* ]
* })
* ```
*
* @example
* ```typescript
* // Development environment with validation disabled
* export default defineConfig({
* branches: ['main'],
* plugins: ['@semantic-release/commit-analyzer']
* }, {
* environment: 'development',
* validate: false // Skip validation for dynamic configs
* })
* ```
*
* @example
* ```typescript
* // Complex configuration with custom plugins
* export default defineConfig({
* branches: [
* 'main',
* { name: 'next', prerelease: true },
* { name: 'maintenance', range: '1.x.x' }
* ],
* plugins: [
* '@semantic-release/commit-analyzer',
* '@semantic-release/release-notes-generator',
* ['@semantic-release/changelog', {
* changelogFile: 'CHANGELOG.md',
* changelogTitle: '# Release Notes'
* }],
* ['@semantic-release/npm', {
* npmPublish: true
* }],
* ['@semantic-release/github', {
* assets: [
* { path: 'dist/*.tgz', label: 'Distribution' },
* { path: 'coverage/', label: 'Coverage Report' }
* ]
* }],
* ['@semantic-release/git', {
* assets: ['CHANGELOG.md', 'package.json'],
* message: 'chore(release): ${nextRelease.version} [skip ci]'
* }]
* ]
* })
* ```
*
* @see {@link DefineConfigOptions} for available configuration options
* @see {@link https://semantic-release.gitbook.io/semantic-release/usage/configuration} for semantic-release configuration documentation
*/
declare function defineConfig<T extends GlobalConfig>(config: T, options?: DefineConfigOptions): T;
/**
* Legacy defineConfig function for backward compatibility.
*
* This maintains the exact same API as the original function while adding
* validation under the hood. Recommended for migration scenarios where
* minimal changes are required.
*
* **Migration Note:** Consider using the main `defineConfig` function with
* explicit options for better control over validation and environment handling.
*
* @param config - Semantic-release configuration object
* @returns Validated semantic-release configuration
*
* @deprecated Consider using `defineConfig(config, { validate: true })` instead
*
* @example
* ```typescript
* // Legacy usage (still supported)
* export default defineConfigLegacy({
* branches: ['main'],
* plugins: ['@semantic-release/npm']
* })
* ```
*
* @example
* ```typescript
* // Recommended migration approach
* export default defineConfig({
* branches: ['main'],
* plugins: ['@semantic-release/npm']
* }, {
* validate: true // Explicit validation control
* })
* ```
*/
declare function defineConfigLegacy<T extends GlobalConfig>(config: T): T;
/**
* Environment-specific configuration utilities for semantic-release.
*
* This module provides comprehensive environment detection and configuration
* transformation utilities to support different deployment environments
* (development, staging, production, test) with appropriate defaults and
* optimizations for each context.
*/
/**
* Supported environment types for semantic-release configurations.
*/
type Environment = 'development' | 'staging' | 'production' | 'test';
/**
* Environment detection result with metadata.
*/
interface EnvironmentContext {
/**
* The detected or explicitly set environment.
*/
environment: Environment;
/**
* Whether the environment was auto-detected or explicitly set.
*/
autoDetected: boolean;
/**
* Source of the environment detection (e.g., 'NODE_ENV', 'CI', 'explicit').
*/
source: string;
/**
* Whether we're running in a CI environment.
*/
isCI: boolean;
/**
* Additional metadata about the detected environment.
*/
metadata: {
nodeEnv?: string;
ciVendor?: string;
branchName?: string;
};
}
/**
* Environment-specific configuration transformations.
*/
interface EnvironmentTransformations {
/**
* Branch configuration modifications.
*/
branches?: string[] | undefined;
/**
* CI mode configuration.
*/
ci?: boolean;
/**
* Dry-run mode configuration.
*/
dryRun?: boolean;
/**
* Debug mode configuration.
*/
debug?: boolean;
/**
* Repository URL modifications.
*/
repositoryUrl?: string;
/**
* Tag format modifications.
*/
tagFormat?: string;
/**
* Plugin configuration transformations.
*/
plugins?: (string | [string, any])[];
}
/**
* Detect the current environment based on various indicators.
*
* @param explicitEnv - Explicitly specified environment (overrides detection)
* @returns Environment context with detection metadata
*/
declare function detectEnvironment(explicitEnv?: Environment): EnvironmentContext;
/**
* Get environment-specific configuration transformations.
*
* @param environment - Target environment
* @param context - Environment context with detection metadata
* @returns Configuration transformations for the environment
*/
declare function getEnvironmentTransformations(environment: Environment, context: EnvironmentContext): EnvironmentTransformations;
/**
* Apply environment-specific transformations to a configuration.
*
* @param config - Base configuration to transform
* @param environment - Target environment
* @param context - Environment context with detection metadata
* @returns Transformed configuration
*/
declare function applyEnvironmentTransformations(config: GlobalConfig, environment: Environment, context: EnvironmentContext): GlobalConfig;
/**
* Create environment-specific configuration presets.
*/
declare const environmentPresets: {
/**
* Development environment preset with safe defaults.
*/
readonly development: {
readonly branches: readonly ["main", "master", "develop", "development"];
readonly dryRun: true;
readonly debug: true;
readonly ci: false;
readonly tagFormat: "v${version}-dev";
};
/**
* Test environment preset optimized for testing.
*/
readonly test: {
readonly branches: readonly ["main", "master"];
readonly dryRun: true;
readonly debug: true;
readonly ci: true;
readonly tagFormat: "v${version}-test";
};
/**
* Staging environment preset for pre-production testing.
*/
readonly staging: {
readonly branches: readonly ["staging", "stage", "main"];
readonly dryRun: false;
readonly debug: true;
readonly ci: true;
readonly tagFormat: "v${version}-staging";
};
/**
* Production environment preset for production releases.
*/
readonly production: {
readonly branches: readonly ["main", "master"];
readonly dryRun: false;
readonly debug: false;
readonly ci: true;
readonly tagFormat: "v${version}";
};
};
/**
* Type-safe plugin configuration helpers for popular semantic-release plugins.
*
* This module provides helper functions that create properly typed and validated
* configurations for popular semantic-release plugins, enhancing the developer
* experience with IntelliSense support and runtime validation.
*/
/**
* Create a type-safe configuration for @semantic-release/commit-analyzer plugin.
*
* @param config - Plugin configuration options
* @returns Plugin specification tuple
*/
declare function commitAnalyzer(config?: CommitAnalyzerConfig): PluginSpec$1;
/**
* Create a type-safe configuration for @semantic-release/release-notes-generator plugin.
*
* @param config - Plugin configuration options
* @returns Plugin specification tuple
*/
declare function releaseNotesGenerator(config?: ReleaseNotesGeneratorConfig): PluginSpec$1;
/**
* Create a type-safe configuration for @semantic-release/changelog plugin.
*
* @param config - Plugin configuration options
* @returns Plugin specification tuple
*/
declare function changelog(config?: ChangelogConfig): PluginSpec$1;
/**
* Create a type-safe configuration for @semantic-release/npm plugin.
*
* @param config - Plugin configuration options
* @returns Plugin specification tuple
*/
declare function npm(config?: NpmConfig): PluginSpec$1;
/**
* Create a type-safe configuration for @semantic-release/github plugin.
*
* @param config - Plugin configuration options
* @returns Plugin specification tuple
*/
declare function github(config?: GithubConfig): PluginSpec$1;
/**
* Create a type-safe configuration for @semantic-release/git plugin.
*
* @param config - Plugin configuration options
* @returns Plugin specification tuple
*/
declare function git(config?: GitConfig): PluginSpec$1;
/**
* Collection of commonly used plugin configurations as presets.
*/
declare const pluginPresets: {
/**
* Standard commit analyzer with conventional commits preset.
*/
readonly standardCommitAnalyzer: PluginSpec$1;
/**
* Standard release notes generator with conventional commits preset.
*/
readonly standardReleaseNotes: PluginSpec$1;
/**
* Standard changelog configuration.
*/
readonly standardChangelog: PluginSpec$1;
/**
* NPM plugin configured for public package publishing.
*/
readonly npmPublicPackage: PluginSpec$1;
/**
* NPM plugin configured for private package publishing.
*/
readonly npmPrivatePackage: PluginSpec$1;
/**
* GitHub plugin with standard configuration.
*/
readonly githubStandard: PluginSpec$1;
/**
* Git plugin with standard commit configuration.
*/
readonly gitStandard: PluginSpec$1;
};
/**
* Preset factory functions for common semantic-release workflows.
*
* This module provides pre-configured semantic-release setups for common
* scenarios like npm packages, GitHub releases, and monorepo workflows.
* Each preset encapsulates best practices and proven configurations for
* specific use cases, enabling quick setup with minimal configuration.
*
* **Available Presets:**
* - `npmPreset()` - Full npm package workflow with changelog and GitHub releases
* - `githubPreset()` - GitHub releases only, no npm publishing
* - `monorepoPreset()` - Monorepo-aware configuration with package-specific tagging
*
* @example
* ```typescript
* // NPM package with standard workflow
* import { npmPreset } from '@bfra.me/semantic-release/presets'
*
* export default npmPreset({
* branches: ['main', { name: 'beta', prerelease: true }]
* })
* ```
*
* @example
* ```typescript
* // GitHub releases only
* import { githubPreset } from '@bfra.me/semantic-release/presets'
*
* export default githubPreset({
* branches: ['main']
* })
* ```
*
* @example
* ```typescript
* // Monorepo package
* import { monorepoPreset } from '@bfra.me/semantic-release/presets'
*
* export default monorepoPreset({
* packageName: 'my-package',
* branches: ['main']
* })
* ```
*/
/**
* Base preset options that can be applied to any preset.
*
* These options provide common configuration patterns that work across
* all preset types, allowing for consistent customization.
*/
interface BasePresetOptions {
/**
* Branches configuration for release workflow.
*
* Defines which branches can trigger releases and how they're handled.
* Supports both production and prerelease branch configurations.
*
* @default ['main']
*
* @example
* ```typescript
* // Simple main branch only
* branches: ['main']
*
* // Production + prerelease branches
* branches: [
* 'main',
* { name: 'beta', prerelease: true },
* { name: 'alpha', prerelease: 'alpha' }
* ]
* ```
*/
branches?: GlobalConfig['branches'];
/**
* Repository URL if not auto-detected from Git remotes.
*
* Useful when running in environments where Git remotes aren't properly
* configured or when you need to override the detected repository URL.
*
* @example 'https://github.com/owner/repo.git'
* @example 'git@github.com:owner/repo.git'
*/
repositoryUrl?: string;
/**
* Enable dry-run mode for testing configurations.
*
* When enabled, semantic-release will analyze commits and generate
* release notes but won't actually publish anything. Useful for
* testing and CI pipeline validation.
*
* @default false
*
* @example
* ```typescript
* // Test mode
* dryRun: true
*
* // Environment-based
* dryRun: process.env.NODE_ENV !== 'production'
* ```
*/
dryRun?: boolean;
/**
* Additional configuration options for the defineConfig function.
*
* Allows passing validation options, environment settings, and other
* advanced configuration options to the underlying defineConfig call.
*
* @example
* ```typescript
* defineOptions: {
* validate: true,
* environment: 'production'
* }
* ```
*/
defineOptions?: DefineConfigOptions;
}
/**
* Create an npm package release preset with comprehensive workflow.
*
* This preset is optimized for standard npm package releases and includes:
* - Conventional commit analysis
* - Automated release notes generation
* - CHANGELOG.md file maintenance
* - npm package publishing
* - GitHub release creation
* - Git commits for changelog updates
*
* **Included Plugins:**
* - `@semantic-release/commit-analyzer` - Analyzes commits for release type
* - `@semantic-release/release-notes-generator` - Generates release notes
* - `@semantic-release/changelog` - Maintains CHANGELOG.md file
* - `@semantic-release/npm` - Publishes to npm registry
* - `@semantic-release/github` - Creates GitHub releases
* - `@semantic-release/git` - Commits changelog changes back to repository
*
* @param options - Configuration options for the npm preset
* @returns A complete semantic-release configuration optimized for npm packages
*
* @example
* ```typescript
* // Basic npm package configuration
* export default npmPreset({
* branches: ['main']
* })
* ```
*
* @example
* ```typescript
* // npm package with prerelease support
* export default npmPreset({
* branches: [
* 'main',
* { name: 'beta', prerelease: true },
* { name: 'alpha', prerelease: true }
* ]
* })
* ```
*
* @example
* ```typescript
* // Testing configuration
* export default npmPreset({
* branches: ['main'],
* dryRun: true, // Test without publishing
* defineOptions: {
* validate: true // Enable strict validation
* }
* })
* ```
*/
declare function npmPreset(options?: BasePresetOptions): GlobalConfig;
/**
* Create a GitHub-only release preset without npm publishing.
*
* This preset is optimized for projects that only need GitHub releases
* without npm publishing or local file modifications. Perfect for:
* - Applications that don't publish to package registries
* - Docker-based projects
* - Binary releases
* - Documentation sites
*
* **Included Plugins:**
* - `@semantic-release/commit-analyzer` - Analyzes commits for release type
* - `@semantic-release/release-notes-generator` - Generates release notes
* - `@semantic-release/github` - Creates GitHub releases with assets
*
* @param options - Configuration options for the GitHub preset
* @returns A complete semantic-release configuration for GitHub-only releases
* @example
* ```typescript
* // Basic GitHub releases
* export default githubPreset({
* branches: ['main']
* })
* ```
*/
declare function githubPreset(options?: BasePresetOptions): GlobalConfig;
/**
* Create a monorepo package release preset.
*
* This preset is optimized for packages within a monorepo, supporting
* workspace-specific tagging, conditional publishing, and integration
* with changesets workflow for coordinated releases.
*
* @param options - Configuration options for the monorepo preset
* @returns A complete semantic-release configuration for monorepo packages
*
* @example
* ```typescript
* // Basic monorepo package
* export default monorepoPreset({
* branches: ['main'],
* packageName: '@org/package-name'
* })
*
* // With changesets integration
* export default monorepoPreset({
* branches: ['main'],
* packageName: '@org/package-name',
* changesetsIntegration: true,
* pkgRoot: 'packages/my-package'
* })
* ```
*/
declare function monorepoPreset(options?: BasePresetOptions & {
/**
* Package root directory for monorepo packages.
*/
pkgRoot?: string;
/**
* Package name for release tagging.
*/
packageName?: string;
/**
* Enable integration with changesets workflow.
* When enabled, optimizes for coordinated releases in monorepos.
* @default false
*/
changesetsIntegration?: boolean;
/**
* Whether to only publish if there are actual changes.
* Useful with changesets to avoid empty releases.
* @default true when changesetsIntegration is enabled
*/
publishOnlyIfChanged?: boolean;
/**
* Custom release notes template for monorepo context.
*/
releaseNotesTemplate?: string;
}): GlobalConfig;
/**
* Create a development/testing preset.
*
* This preset is optimized for development and testing with dry-run enabled
* and enhanced debugging capabilities.
*
* @param options - Base configuration to enhance for development
* @returns A development-optimized semantic-release configuration
*
* @example
* ```typescript
* // Development preset
* export default developmentPreset({
* branches: ['develop', 'feature/*']
* })
* ```
*/
declare function developmentPreset(options?: BasePresetOptions): GlobalConfig;
/**
* Available preset types for easy reference.
*/
declare const presets: {
readonly npm: typeof npmPreset;
readonly github: typeof githubPreset;
readonly monorepo: typeof monorepoPreset;
readonly development: typeof developmentPreset;
};
/**
* Get a preset by name with type safety.
*
* @param name - Preset name
* @returns The preset function
*
* @example
* ```typescript
* const preset = getPreset('npm')
* export default preset({ branches: ['main'] })
* ```
*/
declare function getPreset<T extends keyof typeof presets>(name: T): (typeof presets)[T];
/**
* Preset versioning and migration utilities for semantic-release configurations.
*
* This module provides utilities for managing preset versions, detecting compatibility,
* and migrating configurations between different preset versions.
*/
/**
* Preset version information.
*/
interface PresetVersion {
/**
* The version identifier (e.g., '1.0.0', '2.1.0').
*/
version: string;
/**
* When this version was released.
*/
releaseDate: Date;
/**
* Whether this version contains breaking changes.
*/
breaking: boolean;
/**
* Description of changes in this version.
*/
description: string;
/**
* Migration path from previous versions.
*/
migrations?: PresetMigration[];
/**
* Compatibility information.
*/
compatibility: {
/**
* Minimum semantic-release version required.
*/
semanticRelease: string;
/**
* Node.js version requirements.
*/
node: string;
/**
* Compatible preset versions that can be mixed.
*/
presets?: string[];
};
}
/**
* Preset migration definition.
*/
interface PresetMigration {
/**
* Source version range this migration applies to.
*/
from: string;
/**
* Target version this migration produces.
*/
to: string;
/**
* Whether this migration has breaking changes.
*/
breaking: boolean;
/**
* Description of the migration.
*/
description: string;
/**
* Migration transform function.
*/
transform: (config: GlobalConfig) => GlobalConfig;
/**
* Validation function to check if migration is needed.
*/
isApplicable?: (config: GlobalConfig) => boolean;
/**
* Post-migration validation.
*/
validate?: (config: GlobalConfig) => {
valid: boolean;
errors?: string[];
};
}
/**
* Preset registry with version information.
*/
interface PresetRegistry {
/**
* Registry of available preset versions.
*/
presets: Record<string, PresetVersion[]>;
/**
* Currently active versions.
*/
current: Record<string, string>;
/**
* Migration paths between versions.
*/
migrations: Record<string, PresetMigration[]>;
}
/**
* Configuration migration result.
*/
interface MigrationResult {
/**
* Whether migration was successful.
*/
success: boolean;
/**
* Migrated configuration (if successful).
*/
config?: GlobalConfig;
/**
* Version after migration.
*/
version?: string;
/**
* Migration steps that were applied.
*/
appliedMigrations?: string[];
/**
* Warnings encountered during migration.
*/
warnings?: string[];
/**
* Errors that prevented migration.
*/
errors?: string[];
}
/**
* Version compatibility check result.
*/
interface CompatibilityResult {
/**
* Whether versions are compatible.
*/
compatible: boolean;
/**
* Compatibility issues found.
*/
issues?: CompatibilityIssue[];
/**
* Suggested actions to resolve issues.
*/
suggestions?: string[];
}
/**
* Compatibility issue information.
*/
interface CompatibilityIssue {
/**
* Type of compatibility issue.
*/
type: 'version-mismatch' | 'breaking-change' | 'dependency-conflict' | 'feature-removed';
/**
* Affected component or feature.
*/
component: string;
/**
* Description of the issue.
*/
description: string;
/**
* Severity of the issue.
*/
severity: 'error' | 'warning' | 'info';
/**
* Suggested resolution.
*/
resolution?: string;
}
/**
* Preset versioning manager.
*/
declare class PresetVersionManager {
private readonly registry;
constructor(registry?: PresetRegistry);
/**
* Get available versions for a preset.
*/
getAvailableVersions(presetName: string): PresetVersion[];
/**
* Get current version for a preset.
*/
getCurrentVersion(presetName: string): string | undefined;
/**
* Get version information for a specific preset version.
*/
getVersionInfo(presetName: string, version: string): PresetVersion | undefined;
/**
* Check compatibility between preset versions.
*/
checkCompatibility(presetName: string, fromVersion: string, toVersion: string): CompatibilityResult;
/**
* Migrate a configuration to a newer preset version.
*/
migrateConfig(config: GlobalConfig, presetName: string, fromVersion: string, toVersion: string): MigrationResult;
/**
* Find migration path between two versions.
*/
private findMigrationPath;
/**
* Compare two version strings.
*/
private compareVersions;
/**
* Check if a version is compatible with a requirement range.
*/
private isVersionCompatible;
/**
* Check if a version is in a given range.
*/
private isVersionInRange;
}
/**
* Create a new preset version manager.
*/
declare function createVersionManager(registry?: PresetRegistry): PresetVersionManager;
/**
* Default preset version manager instance.
*/
declare const defaultVersionManager: PresetVersionManager;
/**
* Check compatibility between preset versions.
*/
declare function checkPresetCompatibility(presetName: string, fromVersion: string, toVersion: string): CompatibilityResult;
/**
* Migrate a configuration to a newer preset version.
*/
declare function migratePresetConfig(config: GlobalConfig, presetName: string, fromVersion: string, toVersion: string): MigrationResult;
/**
* Get available versions for a preset.
*/
declare function getPresetVersions(presetName: string): PresetVersion[];
/**
* Get current version for a preset.
*/
declare function getCurrentPresetVersion(presetName: string): string | undefined;
/**
* TypeScript interfaces for semantic-release plugin context objects.
*
* This module provides comprehensive type definitions for the context objects
* passed to each plugin lifecycle stage, based on the semantic-release
* plugin development documentation.
*/
/**
* Plugin configuration type.
* Can be any object with string keys and unknown values.
*/
type PluginConfig$1 = Record<string, unknown>;
/**
* Git commit information.
*/
interface Commit {
/**
* Commit object with hash information.
*/
commit: {
/**
* Full commit hash.
*/
long: string;
/**
* Short commit hash.
*/
short: string;
};
/**
* Tree object with hash information.
*/
tree: {
/**
* Full tree hash.
*/
long: string;
/**
* Short tree hash.
*/
short: string;
};
/**
* Commit author information.
*/
author: {
/**
* Author name.
*/
name: string;
/**
* Author email.
*/
email: string;
/**
* Author date (ISO 8601 timestamp).
*/
date: string;
};
/**
* Commit committer information.
*/
committer: {
/**
* Committer name.
*/
name: string;
/**
* Committer email.
*/
email: string;
/**
* Committer date (ISO 8601 timestamp).
*/
date: string;
};
/**
* Commit message subject.
*/
subject: string;
/**
* Commit message body.
*/
body: string;
/**
* Commit hash (same as commit.long).
*/
hash: string;
/**
* Committer date (ISO 8601 timestamp).
*/
committerDate: string;
/**
* Full commit message.
*/
message: string;
/**
* Git tags associated with the commit.
*/
gitTags: string;
}
/**
* Release information.
*/
interface Release {
/**
* Release version (without 'v' prefix).
*/
version: string;
/**
* Git tag for the release (with 'v' prefix).
*/
gitTag: string;
/**
* Release channels.
*/
channels: readonly string[];
/**
* Git commit hash for the release.
*/
gitHead: string;
/**
* Release name.
*/
name?: string;
/**
* Release notes.
*/
notes?: string;
}
/**
* Next release information with additional fields.
*/
interface NextRelease extends Release {
/**
* Release type ('major', 'minor', 'patch', etc.).
*/
type: string;
/**
* Release channel.
*/
channel: string;
}
/**
* Branch information.
*/
interface Branch {
/**
* Branch channel.
*/
channel: string;
/**
* Branch tags configuration.
*/
tags: Record<string, unknown>;
/**
* Branch type.
*/
type: string;
/**
* Branch name.
*/
name: string;
/**
* Branch range.
*/
range: string;
/**
* Branch accept pattern.
*/
accept: readonly string[];
/**
* Whether this is the main branch.
*/
main: boolean;
}
/**
* CI environment information.
*/
interface CiEnvironment {
/**
* Whether running in a CI environment.
*/
isCi: boolean;
/**
* Current commit hash.
*/
commit: string;
/**
* Current branch name.
*/
branch: string;
/**
* Additional CI-specific properties.
*/
[key: string]: unknown;
}
/**
* Logger interface for plugin logging.
*/
interface Logger {
/**
* Log an informational message.
*/
log: (message: string, ...args: unknown[]) => void;
/**
* Log a warning message.
*/
warn: (message: string, ...args: unknown[]) => void;
/**
* Log a success message.
*/
success: (message: string, ...args: unknown[]) => void;
/**
* Log an error message.
*/
error: (message: string, ...args: unknown[]) => void;
/**
* Log a debug message.
*/
debug?: (message: string, ...args: unknown[]) => void;
}
/**
* Base context object shared by all lifecycle hooks.
*/
interface BaseContext {
/**
* Current working directory.
*/
cwd: string;
/**
* Environment variables.
*/
env: Record<string, string | undefined>;
/**
* CI environment information.
*/
envCi: CiEnvironment;
/**
* Options passed to semantic-release.
*/
options: Record<string, unknown>;
/**
* Current branch information.
*/
branch: Branch;
/**
* All branches configuration.
*/
branches: readonly Branch[];
/**
* Logger instance for plugin output.
*/
logger: Logger;
/**
* Standard output stream.
*/
stdout: NodeJS.WriteStream;
/**
* Standard error stream.
*/
stderr: NodeJS.WriteStream;
}
/**
* Context for verifyConditions lifecycle hook.
*/
interface VerifyConditionsContext extends BaseContext {
}
/**
* Context for analyzeCommits lifecycle hook.
*/
interface AnalyzeCommitsContext extends BaseContext {
/**
* List of commits to analyze.
*/
commits: readonly Commit[];
/**
* Existing releases.
*/
releases: readonly Release[];
/**
* Last release information.
*/
lastRelease: Release;
}
/**
* Result type for analyzeCommits lifecycle hook.
*/
type AnalyzeCommitsResult = 'major' | 'premajor' | 'minor' | 'preminor' | 'patch' | 'prepatch' | 'prerelease' | string | null | undefined;
/**
* Context for verifyRelease lifecycle hook.
*/
interface VerifyReleaseContext extends BaseContext {
/**
* Commits for the release.
*/
commits: readonly Commit[];
/**
* Next release information.
*/
nextRelease: NextRelease;
/**
* Existing releases.
*/
releases: readonly Release[];
/**
* Last release information.
*/
lastRelease: Release;
}
/**
* Context for generateNotes lifecycle hook.
*/
interface GenerateNotesContext extends BaseContext {
/**
* Commits for the release.
*/
commits: readonly Commit[];
/**
* Next release information.
*/
nextRelease: NextRelease;
/**
* Existing releases.
*/
releases: readonly Release[];
/**
* Last release information.
*/
lastRelease: Release;
}
/**
* Result type for generateNotes lifecycle hook.
*/
type GenerateNotesResult = string;
/**
* Context for prepare lifecycle hook.
*/
interface PrepareContext extends BaseContext {
/**
* Commits for the release.
*/
commits: readonly Commit[];
/**
* Next release information (with populated notes).
*/
nextRelease: NextRelease & {
notes: string;
};
/**
* Existing releases.
*/
releases: readonly Release[];
/**
* Last release information.
*/
lastRelease: Release;
}
/**
* Context for publish lifecycle hook.
*/
interface PublishContext extends BaseContext {
/**
* Commits for the release.
*/
commits: readonly Commit[];
/**
* Next release information (with populated notes).
*/
nextRelease: NextRelease & {
notes: string;
};
/**
* Existing releases.
*/
releases: readonly Release[];
/**
* Last release information.
*/
lastRelease: Release;
}
/**
* Result type for publish lifecycle hook.
*/
interface PublishResult {
/**
* Name of the published release.
*/
name: string;
/**
* URL of the published release.
*/
url: string;
}
/**
* Context for success lifecycle hook.
*/
interface SuccessContext extends BaseContext {
/**
* Commits for the release.
*/
commits: readonly Commit[];
/**
* Next release information.
*/
nextRelease: NextRelease;
/**
* All releases (populated by publish lifecycle).
*/
releases: readonly (Release & {
name: string;
url: string;
})[];
/**
* Last release information.
*/
lastRelease: Release;
}
/**
* Context for fail lifecycle hook.
*/
interface FailContext extends BaseContext {
/**
* Commits that were being processed.
*/
commits?: readonly Commit[];
/**
* Next release information (if available).
*/
nextRelease?: NextRelease;
/**
* Existing releases.
*/
releases?: readonly Release[];
/**
* Last release information (if available).
*/
lastRelease?: Release;
/**
* Errors that caused the failure.
*/
errors: readonly Error[];
}
/**
* TypeScript interfaces for semantic-release plugin lifecycle hooks.
*
* This module provides comprehensive type definitions for all semantic-release
* plugin lifecycle methods, enabling type-safe plugin development with full
* IntelliSense support.
*/
/**
* Base type for all plugin lifecycle hooks.
*
* Each lifecycle hook receives plugin configuration and a context object
* with semantic-release runtime information.
*/
type BaseLifecycleHook<TConfig = PluginConfig$1, TContext = BaseContext> = (pluginConfig: TConfig, context: TContext) => Promise<void> | void;
/**
* Verify conditions lifecycle hook.
*
* Called by semantic-release to validate plugin configuration and environment.
* Should throw an error if conditions are not met for the plugin to work properly.
*
* @param pluginConfig - Plugin-specific configuration options
* @param context - Semantic-release context with environment and configuration
*/
type VerifyConditionsHook<TConfig = PluginConfig$1> = BaseLifecycleHook<TConfig, VerifyConditionsContext>;
/**
* Analyze commits lifecycle hook.
*
* Called by semantic-release to determine the type of release based on commits.
* Should return the release type or undefined if no release is needed.
*
* @param pluginConfig - Plugin-specific configuration options
* @param context - Semantic-release context with commits and release information
* @returns Release type ('major', 'minor', 'patch', etc.) or undefined
*/
type AnalyzeCommitsHook<TConfig = PluginConfig$1> = (pluginConfig: TConfig, context: AnalyzeCommitsContext) => Promise<AnalyzeCommitsResult> | AnalyzeCommitsResult;
/**
* Verify release lifecycle hook.
*
* Called by semantic-release to validate the release before proceeding.
* Should throw an error if the release should be blocked.
*
* @param pluginConfig - Plugin-specific configuration options
* @param context - Semantic-release context with next release information
*/
type VerifyReleaseHook<TConfig = PluginConfig$1> = BaseLifecycleHook<TConfig, VerifyReleaseContext>;
/**
* Generate notes lifecycle hook.
*
* Called by semantic-release to create release notes.
* Should return the release notes as a string.
*
* @param pluginConfig - Plugin-specific configuration options
* @param context - Semantic-release context with commits and release information
* @returns Release notes as string
*/
type GenerateNotesHook<TConfig = PluginConfig$1> = (pluginConfig: TConfig, context: GenerateNotesContext) => Promise<GenerateNotesResult> | GenerateNotesResult;
/**
* Prepare lifecycle hook.
*
* Called by semantic-release to prepare the release (e.g., update files, create changelog).
* Should perform any necessary file updates or preparations before publishing.
*
* @param pluginConfig - Plugin-specific configuration options
* @param context - Semantic-release context with next release and notes
*/
type PrepareHook<TConfig = PluginConfig$1> = BaseLifecycleHook<TConfig, PrepareContext>;
/**
* Publish lifecycle hook.
*
* Called by semantic-release to publish the release.
* Should return publication information with name and URL.
*
* @param pluginConfig - Plugin-specific configuration options
* @param context - Semantic-release context with release information
* @returns Publication result with name and URL, or void
*/
type PublishHook<TConfig = PluginConfig$1> = (pluginConfig: TConfig, context: PublishContext) => Promise<PublishResult | void> | PublishResult | void;
/**
* Success lifecycle hook.
*
* Called by semantic-release after a successful release.
* Should perform any post-release notifications or cleanup.
*
* @param pluginConfig - Plugin-specific configuration options
* @param context - Semantic-release context with successful releases
*/
type SuccessHook<TConfig = PluginConfig$1> = BaseLifecycleHook<TConfig, SuccessContext>;
/**
* Fail lifecycle hook.
*
* Called by semantic-release when the release process fails.
* Should perform any error notifications or cleanup.
*
* @param pluginConfig - Plugin-specific configuration options
* @param context - Semantic-release context with error information
*/
type FailHook<TConfig = PluginConfig$1> = BaseLifecycleHook<TConfig, FailContext>;
/**
* Complete plugin lifecycle hooks interface.
*
* A plugin can implement any subset of these lifecycle hooks.
* At least one hook must be implemented for a valid plugin.
*/
interface PluginLifecycleHo