@kb-labs/release-manager-core 2.100.0 → 2.101.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -11,6 +11,16 @@ interface PluginLogger {
11
11
  }
12
12
  type ReleaseStage = 'planning' | 'checking' | 'versioning' | 'publishing' | 'verifying' | 'rollback';
13
13
  type VersionBump = 'patch' | 'minor' | 'major' | 'auto';
14
+ /**
15
+ * Release track. Orthogonal to VersionBump — bump decides how much to
16
+ * increment, channel decides which track a release ships on.
17
+ * - 'stable': normal versioned release, committed to git, publishes to
18
+ * `config.registry` (typically Verdaccio for pre-promote validation).
19
+ * - 'canary': prerelease published straight to real npm under a dist-tag,
20
+ * with an in-memory `-canary.<shortsha>` version that is never committed
21
+ * to package.json/git.
22
+ */
23
+ type ReleaseChannel = 'stable' | 'canary';
14
24
  interface ReleaseContext {
15
25
  repo: string;
16
26
  cwd: string;
@@ -34,6 +44,7 @@ interface ReleasePlan {
34
44
  strategy: 'semver';
35
45
  registry: string;
36
46
  rollbackEnabled: boolean;
47
+ channel: ReleaseChannel;
37
48
  }
38
49
  interface CheckResultDetails {
39
50
  /** Which package path this failure came from (for perPackage checks). */
@@ -137,6 +148,8 @@ interface ReleaseConfig {
137
148
  registry?: string;
138
149
  strategy?: 'semver';
139
150
  bump?: VersionBump;
151
+ /** Release track. Defaults to 'stable' when omitted. See ReleaseChannel. */
152
+ channel?: ReleaseChannel;
140
153
  versioningStrategy?: 'lockstep' | 'independent' | 'adaptive';
141
154
  strict?: boolean;
142
155
  verify?: CheckId[];
@@ -148,6 +161,20 @@ interface ReleaseConfig {
148
161
  access?: 'public' | 'restricted';
149
162
  /** Package manager to use for publishing. Default: 'pnpm'. */
150
163
  packageManager?: 'pnpm' | 'npm' | 'yarn';
164
+ /** npm dist-tag for canary publishes. Default: 'canary'. */
165
+ canaryTag?: string;
166
+ /** npm dist-tag for stable promote-to-npm. Default: 'latest'. */
167
+ stableTag?: string;
168
+ /**
169
+ * Real npm registry used for canary publishes and for `kb release
170
+ * promote`. Deliberately separate from `registry` (which controls
171
+ * where a 'stable' `release run` publishes — typically Verdaccio) so a
172
+ * stale Verdaccio `registry` value can't accidentally swallow a canary
173
+ * publish or a promote. Default: 'https://registry.npmjs.org'.
174
+ */
175
+ npmRegistry?: string;
176
+ /** Timeout (ms) for registry-verification HTTP calls before promoting a stable release. Default: 30000. */
177
+ verifyRegistryTimeoutMs?: number;
151
178
  };
152
179
  /** Workspace configuration — package manager used for publishing. */
153
180
  workspace?: {
@@ -259,6 +286,8 @@ interface PackagePublisher {
259
286
  publish(packages: PublishablePackage[], options: {
260
287
  dryRun?: boolean;
261
288
  access?: string;
289
+ tag?: string;
290
+ registry?: string;
262
291
  }): Promise<PublishResult>;
263
292
  }
264
293
  /** Injected by caller — generates changelog */
@@ -312,6 +341,8 @@ interface PlannerOptions {
312
341
  /** Named flow — selects a release config profile. Completely replaces global packages/versioning/checks. */
313
342
  flow?: string;
314
343
  bumpOverride?: VersionBump;
344
+ /** Release track. Defaults to 'stable'. See ReleaseChannel. */
345
+ channel?: ReleaseChannel;
315
346
  }
316
347
  /**
317
348
  * Merge base config with a named flow's config.
@@ -319,6 +350,19 @@ interface PlannerOptions {
319
350
  * All other config fields (registry, publish, rollback, git, changelog) remain from global.
320
351
  */
321
352
  declare function mergeConfigWithFlow(config: ReleaseConfig, flowName: string): ReleaseConfig;
353
+ /**
354
+ * Check whether a specific package version is already published on the npm registry.
355
+ * Fail-open: returns false on any network/registry error.
356
+ */
357
+ declare function isVersionPublished(name: string, version: string, registry: string): Promise<boolean>;
358
+ /**
359
+ * Discover release-candidate packages for a scope, at their CURRENT
360
+ * package.json version — no git-diff-based bump computation. Shared by
361
+ * planRelease() (which then computes bumps on top) and `kb release
362
+ * promote` (which needs the already-released versions as-is, since
363
+ * recomputing bumps from git history would be wrong for a promote).
364
+ */
365
+ declare function discoverCurrentPackages(cwd: string, scope: string | undefined, config: ReleaseConfig): Promise<PackageVersion[]>;
322
366
  /**
323
367
  * Plan release by detecting changes and computing version bumps
324
368
  */
@@ -331,28 +375,10 @@ declare function planRelease(options: PlannerOptions): Promise<ReleasePlan>;
331
375
  */
332
376
  declare function matchesPackagePattern(pkgName: string, relativePath: string, patterns: string[]): boolean;
333
377
 
334
- interface PublisherOptions {
335
- cwd: string;
336
- plan: ReleasePlan;
337
- dryRun?: boolean;
338
- shell?: ShellAPI;
339
- config?: ReleaseConfig;
340
- }
341
- interface PublishingResult {
342
- published: string[];
343
- skipped: string[];
344
- errors: string[];
345
- versionUpdates: Array<{
346
- package: string;
347
- from: string;
348
- to: string;
349
- updated: boolean;
350
- }>;
351
- }
352
378
  /**
353
- * Publish packages according to plan
379
+ * Publisher - handles package publishing and changelog updates
354
380
  */
355
- declare function publishPackages(options: PublisherOptions): Promise<PublishingResult>;
381
+
356
382
  /**
357
383
  * Update package.json version to nextVersion
358
384
  * Should be called BEFORE generating changelog so versions match
@@ -367,30 +393,6 @@ declare function updatePackageVersions(plan: ReleasePlan): Promise<Array<{
367
393
  to: string;
368
394
  updated: boolean;
369
395
  }>>;
370
- /**
371
- * Generate changelog entry for release
372
- * Note: This is a simplified wrapper. Full changelog generation is handled by @kb-labs/release-manager-changelog
373
- */
374
- declare function generateChangelog(options: {
375
- cwd: string;
376
- plan: ReleasePlan;
377
- }): Promise<string>;
378
- /**
379
- * Generate enhanced changelog using @kb-labs/release-manager-changelog
380
- * This is the recommended approach for full-featured changelog generation
381
- *
382
- * Note: Full integration available via @kb-labs/release-manager-changelog package and CLI command
383
- */
384
- declare function generateEnhancedChangelog(options: {
385
- cwd: string;
386
- plan: ReleasePlan;
387
- from?: string;
388
- to?: string;
389
- config?: ReleaseConfig;
390
- }): Promise<{
391
- changelog: string;
392
- manifest: unknown;
393
- }>;
394
396
  /**
395
397
  * Copy changelog to each package directory
396
398
  * This writes CHANGELOG.md per package with proper header
@@ -446,22 +448,6 @@ declare function saveSnapshot(options: {
446
448
  */
447
449
  declare function restoreSnapshot(cwd: string): Promise<void>;
448
450
 
449
- /**
450
- * Main release runner - orchestrates full release lifecycle
451
- */
452
-
453
- interface RunnerOptions {
454
- config: ReleaseConfig;
455
- context: ReleaseContext;
456
- runChecks?: (stage: ReleaseStage) => Promise<Partial<Record<CheckId, CheckResult>>>;
457
- executePlan?: () => Promise<void>;
458
- onStageChange?: (stage: ReleaseStage) => void;
459
- }
460
- /**
461
- * Run full release process
462
- */
463
- declare function runRelease(options: RunnerOptions): Promise<ReleaseResult>;
464
-
465
451
  /**
466
452
  * JSON reporter for release reports
467
453
  */
@@ -508,6 +494,31 @@ interface StrategyOptions {
508
494
  * Apply versioning strategy to packages
509
495
  */
510
496
  declare function applyVersionStrategy(packages: PackageVersion[], options: StrategyOptions): PackageVersion[];
497
+ /**
498
+ * Apply a canary prerelease suffix to already-computed nextVersion values.
499
+ *
500
+ * Runs AFTER applyVersionStrategy() (lockstep/independent/adaptive) has
501
+ * resolved the base bump — canary is orthogonal to bump size, so it's a
502
+ * pure post-processing step rather than a VersionBump variant. Given a
503
+ * short git SHA, `1.2.3` (base next version) becomes `1.2.3-canary.<sha>`.
504
+ *
505
+ * Deterministic per (nextVersion, shortSha) pair — retrying the same commit
506
+ * reproduces the same canary version, so publish-side idempotency handling
507
+ * (already-published patterns) makes retries safe without extra state.
508
+ */
509
+ declare function applyCanarySuffix(packages: PackageVersion[], shortSha: string): PackageVersion[];
510
+
511
+ /**
512
+ * Resolve the npm dist-tag and target registry for a release channel.
513
+ *
514
+ * Shared by CLI (run.ts), REST (run-handler.ts) and the pipeline itself so
515
+ * "canary always goes to real npm under a canary tag, stable uses whatever
516
+ * config.registry says" is defined once, config-driven, not hardcoded at
517
+ * each call site.
518
+ */
519
+
520
+ declare function resolvePublishTag(config: ReleaseConfig, channel: ReleaseChannel): string;
521
+ declare function resolvePublishRegistry(config: ReleaseConfig, channel: ReleaseChannel): string;
511
522
 
512
523
  /**
513
524
  * Unified release pipeline — single orchestrator for CLI and REST.
@@ -593,6 +604,40 @@ declare function verifyPackages(packages: PackageVersion[], options?: {
593
604
  * npm pack → extract → check exports, directory imports, test leaks, syntax.
594
605
  */
595
606
  declare function verifyPackage(packagePath: string, packageName?: string): VerifyResult;
607
+ /**
608
+ * Run the static artifact checks (test-file leaks, exports existence,
609
+ * directory-import detection, syntax validation) against an already
610
+ * extracted package tarball. Shared by verifyPackage() (local npm pack)
611
+ * and verdaccio-verify.ts (npm pack pulled from a registry) so both
612
+ * "verify before publish" and "verify after publish" use identical checks.
613
+ */
614
+ declare function verifyExtractedTarball(extractedDir: string): string[];
615
+
616
+ /**
617
+ * Registry-side artifact verification — confirms a package actually landed
618
+ * on a registry (Verdaccio) with the expected content, before it's promoted
619
+ * to npm `latest`.
620
+ *
621
+ * Deliberately separate from verifier.ts: that module is pure local
622
+ * validation (npm pack from the working tree, no registry I/O) so it stays
623
+ * usable offline/in restricted CI. This module does registry round-trips —
624
+ * it's the "did the publish actually work, and is what landed still sane"
625
+ * check that only makes sense to run *after* a publish.
626
+ */
627
+
628
+ interface VerifyAgainstRegistryOptions {
629
+ registry: string;
630
+ /** Timeout (ms) for the registry HTTP check and the `npm pack` round-trip. Default: 30000. */
631
+ timeout?: number;
632
+ logger?: Pick<PluginLogger, 'info' | 'warn'>;
633
+ }
634
+ /**
635
+ * Verify that each package landed on `registry` at its expected version,
636
+ * and that the tarball actually published there passes the same static
637
+ * checks verifyPackage() runs pre-publish (catches publish-time corruption
638
+ * distinct from pre-publish source issues).
639
+ */
640
+ declare function verifyAgainstRegistry(packages: PublishablePackage[], options: VerifyAgainstRegistryOptions): Promise<VerifyResult[]>;
596
641
 
597
642
  /**
598
643
  * Scope utilities — resolve scope name to filesystem path.
@@ -618,4 +663,4 @@ declare function verifyPackage(packagePath: string, packageName?: string): Verif
618
663
  */
619
664
  declare function resolveScopePath(repoRoot: string, scope: string): Promise<string>;
620
665
 
621
- export { type AuditSummary, type BuildResult, type ChangelogGenerator, type CheckId, type CheckResult, type CheckResultDetails, type CustomCheckConfig, type FlowConfig, type PackagePublisher, type PackageVersion, type PackagesFilter, type PipelineOptions, type PipelineResult, type PlannerOptions, type PluginLogger, type PublishResult, type PublishablePackage, type PublisherOptions, type PublishingResult, type ReleaseConfig, type ReleaseContext, type ReleasePlan, type ReleaseReport, type ReleaseResult, type ReleaseStage, type RollbackSnapshot, type RunnerOptions, type StrategyOptions, type VerifyResult, type VersionBump, type VersionStrategy, applyVersionStrategy, buildPackages, commitAndTagRelease, copyChangelogToPackages, createExecaShellAdapter, generateChangelog, generateEnhancedChangelog, isBuildCommand, matchesPackagePattern, mergeConfigWithFlow, planRelease, publishPackages, renderJson, renderMarkdown, renderText, resolveScopePath, restoreSnapshot, runRelease, runReleaseChecks, runReleasePipeline, runSafeBuild, saveSnapshot, spawnCommand, updatePackageVersion, updatePackageVersions, verifyPackage, verifyPackages };
666
+ export { type AuditSummary, type BuildResult, type ChangelogGenerator, type CheckId, type CheckResult, type CheckResultDetails, type CustomCheckConfig, type FlowConfig, type PackagePublisher, type PackageVersion, type PackagesFilter, type PipelineOptions, type PipelineResult, type PlannerOptions, type PluginLogger, type PublishResult, type PublishablePackage, type ReleaseChannel, type ReleaseConfig, type ReleaseContext, type ReleasePlan, type ReleaseReport, type ReleaseResult, type ReleaseStage, type RollbackSnapshot, type StrategyOptions, type VerifyResult, type VersionBump, type VersionStrategy, applyCanarySuffix, applyVersionStrategy, buildPackages, commitAndTagRelease, copyChangelogToPackages, createExecaShellAdapter, discoverCurrentPackages, isBuildCommand, isVersionPublished, matchesPackagePattern, mergeConfigWithFlow, planRelease, renderJson, renderMarkdown, renderText, resolvePublishRegistry, resolvePublishTag, resolveScopePath, restoreSnapshot, runReleaseChecks, runReleasePipeline, runSafeBuild, saveSnapshot, spawnCommand, updatePackageVersion, updatePackageVersions, verifyAgainstRegistry, verifyExtractedTarball, verifyPackage, verifyPackages };