class ReleaseManager

Main ReleaseManager class - coordinates the entire release process

Examples

Basic usage with automatic version detection

const config: NagareConfig = {
  project: { name: "My App", repository: "https://github.com/user/app" },
  versionFile: { path: "./version.ts", template: "typescript" }
};

const manager = new ReleaseManager(config);
const result = await manager.release(); // Auto-detects version bump
if (result.success) {
  console.log(`Released version ${result.version}`);
}

CI/CD integration with skip confirmation

const config: NagareConfig = {
  project: { name: "My App", repository: "https://github.com/user/app" },
  versionFile: { path: "./version.ts", template: "typescript" },
  options: {
    skipConfirmation: true,  // No interactive prompts
    logLevel: LogLevel.DEBUG // Verbose output for CI logs
  }
};

const manager = new ReleaseManager(config);
const result = await manager.release("patch");

With intelligent file handlers (v1.1.0+)

const config: NagareConfig = {
  project: { name: "My App", repository: "https://github.com/user/app" },
  versionFile: { path: "./version.ts", template: "typescript" },
  updateFiles: [
    { path: "./deno.json" },     // Auto-detected JSON handler
    { path: "./package.json" },  // Auto-detected JSON handler
    { path: "./README.md" },     // Auto-detected Markdown handler
    {
      path: "./custom.yaml",     // Custom pattern for edge cases
      patterns: {
        version: /^version:\s*['"]?([^'"]+)['"]?$/m
      }
    }
  ]
};

Dry run mode for testing

const config: NagareConfig = {
  project: { name: "My App", repository: "https://github.com/user/app" },
  versionFile: { path: "./version.ts", template: "typescript" },
  options: { dryRun: true }  // Preview without making changes
};

const manager = new ReleaseManager(config);
const result = await manager.release();
// Shows what would happen without actually doing it

Custom commit type mappings

const config: NagareConfig = {
  project: { name: "My App", repository: "https://github.com/user/app" },
  versionFile: { path: "./version.ts", template: "typescript" },
  commitTypes: {
    feat: "added",      // New features
    fix: "fixed",       // Bug fixes
    perf: "improved",   // Performance improvements
    docs: "documented", // Documentation changes
    enhance: "enhanced" // Custom type
  }
};

Constructors

new
ReleaseManager(
config: NagareConfig,
deps?: ReleaseManagerDeps,
)

Constructor with optional dependency injection

Properties

Methods

private
attemptAutoFix(
logs: string,
_version: string,
monitor: GitHubActionsMonitor,
progress: StdProgressIndicator | null,
): Promise<{ success: boolean; jsrUrl?: string; error?: string; }>

Attempt to auto-fix CI/CD errors

private
attemptPreflightAutoFix(result: PreflightResult): Promise<PreflightResult>

Attempt to auto-fix pre-flight check failures

private
buildSafeReplacement(
pattern: RegExp,
newValue: string,
): string

Build safe replacement string for regex patterns

private
createProgressIndicator(): StdProgressIndicator | null

Create progress indicator instance

private
directJsrVerification(
verifier: JsrVerifier,
packageInfo: { scope: string; name: string; version: string; },
_progress: StdProgressIndicator | null,
): Promise<{ success: boolean; jsrUrl?: string; error?: string; attempts?: number; }>

Direct JSR verification without CI/CD monitoring

private
formatChangedFiles(): Promise<void>

Format all changed files after version updates

private
generateReleaseNotes(
version: string,
commits: ConventionalCommit[],
): ReleaseNotes

Generate release notes from commits

Get the current configuration

private
getFilesToBackup(
_newVersion: string,
_releaseNotes: ReleaseNotes,
): string[]

Get list of files to backup before modification

private
getPreflightChecks(): PreflightCheck[]

Get pre-flight checks to run before release

private
getTemplateValue(
keyPath: string,
): string | undefined

Get a value from template data by key path

Merge user config with defaults

private
performPreflightChecks(): Promise<PreflightResult>

Perform pre-flight validation checks

private
previewFileUpdates(templateData: TemplateData): Promise<void>

Preview file updates in dry-run mode

private
previewRelease(releaseNotes: ReleaseNotes | PRReleaseNotes): void

Preview the release changes

release(bumpType?: BumpType): Promise<ReleaseResult>

Main release method - orchestrates the entire release process

private
shouldVerifyJsrPublish(): boolean

Check if JSR publish verification should be performed

private
updateCustomFile(
filePattern: FileUpdatePattern,
templateData: TemplateData,
): Promise<void>

Update a custom file based on patterns with enhanced file handler support

private
updateFiles(
version: string,
releaseNotes: ReleaseNotes | PRReleaseNotes,
): Promise<string[]>

Update all configured files

private
updateVersionFile(templateData: TemplateData): Promise<void>

Update the main version file using template processor

private
validateEnvironment(): Promise<void>

Validate environment and prerequisites

private
validateFileUpdatePatterns(): { valid: boolean; warnings: string[]; errors: string[]; suggestions: string[]; }

Validate file update patterns to detect dangerous configurations

private
validateFileUpdatePatternsEnhanced(): { valid: boolean; warnings: string[]; errors: string[]; suggestions: string[]; }

Validate file update patterns with handler awareness

private
verifyJsrPublication(
version: string,
progress: StdProgressIndicator | null,
): Promise<{ success: boolean; jsrUrl?: string; error?: string; attempts?: number; }>

Verify JSR publication with monitoring and auto-fix

Static Methods

validateConfig(config: NagareConfig): { valid: boolean; errors: string[]; }

Validate configuration