@reelout/core 0.10.0 → 0.11.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/analyzer.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as resolvePackageTag, dt as deriveTransitionReleases, ft as deriveChangeReleases, g as propagateDependencyUpdates, h as readPackageHistory, l as version } from "./workflow-Z9WRyGi8.js";
1
+ import { _ as resolvePackageTag, dt as deriveTransitionReleases, ft as deriveChangeReleases, g as propagateDependencyUpdates, h as readPackageHistory, l as version } from "./workflow-Dk-fKaAx.js";
2
2
  // src/analyzer.ts
3
3
  /**
4
4
  * Built-in plugin that inspects repository history and produces release plans for packages.
package/dist/builder.js CHANGED
@@ -1,4 +1,4 @@
1
- import { M as generateGitTagName, Ut as isSameReleaseCycle, h as readPackageHistory, l as version, p as buildReleaseNotes, qt as bumpVersion, v as resolvePackageStableTag } from "./workflow-Z9WRyGi8.js";
1
+ import { M as generateGitTagName, Ut as isSameReleaseCycle, h as readPackageHistory, l as version, p as buildReleaseNotes, qt as bumpVersion, v as resolvePackageStableTag } from "./workflow-Dk-fKaAx.js";
2
2
  import { t as formatError } from "./formatError-BMsun8Wi.js";
3
3
  import { colors } from "consola/utils";
4
4
  // src/builder.ts
package/dist/changelog.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as resolvePackageTag, b as discoverPackageTag, l as version, m as buildChangelog, s as HookPriority, u as writeChangelog } from "./workflow-Z9WRyGi8.js";
1
+ import { _ as resolvePackageTag, b as discoverPackageTag, l as version, m as buildChangelog, s as HookPriority, u as writeChangelog } from "./workflow-Dk-fKaAx.js";
2
2
  import { t as formatError } from "./formatError-BMsun8Wi.js";
3
3
  import { colors } from "consola/utils";
4
4
  // src/changelog.ts
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as isGitShallowRepository, A as getGitTagMessage, At as execGit, B as getGitRemote, Bt as SEMVER_REGEX, C as iterateChangelogVersions, Ct as readJson, D as isGitTagExact, Dt as isTruthyString, E as buildDependencyGraph, Et as isClass, F as deleteGitTag, Ft as ALL_FILES, G as readGitHistory, Gt as pickPriorityReleaseType, H as getGitConfigValue, Ht as isStableVersion, I as createGitTag, It as DEFAULT_CHANGELOG_FILE, J as detectGitRelationship, Jt as extractVersionQualifier, K as mergeGitHistory, Kt as deriveCommitReleaseType, L as readGitFile, Lt as DEV_NULL, M as generateGitTagName, Mt as compact, N as ensureGitTag, Nt as isDefined, O as isGitTagConnected, Ot as interpolate, P as isGitTagPresent, Pt as buildTrailerPattern, Q as withShallowLock, R as resolveGitRepository, Rt as GIT_TRAILER_RELEASE_AGENT, S as extractLatestVersion, St as unique, T as extractPlainText, Tt as isGitHubActions, U as restoreFullGitHistory, Ut as isSameReleaseCycle, V as ensureGitUserConfig, Vt as promotePrereleaseVersions, W as readParsedGitHistory, Wt as deriveReleaseType, X as resolveGitRevision, Y as expandGitHistory, Z as isGitAncestor, _ as resolvePackageTag, _t as isSemVerGitTag, a as appendReleaseReportSummary, at as parseGitPrettyFormat, b as discoverPackageTag, bt as createPlugin, c as generateReleaseCommitMessage, ct as extractMentions, d as prependChangelog, dt as deriveTransitionReleases, et as countGitHistory, f as extractPreviousVersion, ft as deriveChangeReleases, g as propagateDependencyUpdates, gt as sanitizePrereleaseLabel, h as readPackageHistory, ht as resolveReleaseChannel, i as generateReleaseReport, it as GIT_PRETTY_FORMAT, j as getCurrentGitTag, jt as execCommand, k as getLatestGitTag, kt as formatFile, lt as createGitCommit, m as buildChangelog, mt as resolveVersionQualifier, n as printReleaseReportAnnotation, nt as getParsedGitCommit, o as HookManager, ot as parseGitCommit, p as buildReleaseNotes, pt as packageContainsCommit, q as GIT_REL_FLAGS, qt as bumpVersion, r as printReleaseReport, rt as GIT_PRETTY_FIELD_SEPARATOR, s as HookPriority, st as TTLCache, t as executeReleaseWorkflow, tt as getCurrentGitCommit, u as writeChangelog, ut as getCurrentGitBranch, v as resolvePackageStableTag, vt as isSemVer, w as extractSemVer, wt as isMatch, x as verifyPackageTag, xt as writeJson, y as filterPackages, yt as findReleaseRule, z as pushGitChanges, zt as RELEASE_HOOK_NAMES } from "./workflow-Z9WRyGi8.js";
1
+ import { $ as isGitShallowRepository, A as getGitTagMessage, At as execGit, B as getGitRemote, Bt as SEMVER_REGEX, C as iterateChangelogVersions, Ct as readJson, D as isGitTagExact, Dt as isTruthyString, E as buildDependencyGraph, Et as isClass, F as deleteGitTag, Ft as ALL_FILES, G as readGitHistory, Gt as pickPriorityReleaseType, H as getGitConfigValue, Ht as isStableVersion, I as createGitTag, It as DEFAULT_CHANGELOG_FILE, J as detectGitRelationship, Jt as extractVersionQualifier, K as mergeGitHistory, Kt as deriveCommitReleaseType, L as readGitFile, Lt as DEV_NULL, M as generateGitTagName, Mt as compact, N as ensureGitTag, Nt as isDefined, O as isGitTagConnected, Ot as interpolate, P as isGitTagPresent, Pt as buildTrailerPattern, Q as withShallowLock, R as resolveGitRepository, Rt as GIT_TRAILER_RELEASE_AGENT, S as extractLatestVersion, St as unique, T as extractPlainText, Tt as isGitHubActions, U as restoreFullGitHistory, Ut as isSameReleaseCycle, V as ensureGitUserConfig, Vt as promotePrereleaseVersions, W as readParsedGitHistory, Wt as deriveReleaseType, X as resolveGitRevision, Y as expandGitHistory, Z as isGitAncestor, _ as resolvePackageTag, _t as isSemVerGitTag, a as appendReleaseReportSummary, at as parseGitPrettyFormat, b as discoverPackageTag, bt as createPlugin, c as generateReleaseCommitMessage, ct as extractMentions, d as prependChangelog, dt as deriveTransitionReleases, et as countGitHistory, f as extractPreviousVersion, ft as deriveChangeReleases, g as propagateDependencyUpdates, gt as sanitizePrereleaseLabel, h as readPackageHistory, ht as resolveReleaseChannel, i as generateReleaseReport, it as GIT_PRETTY_FORMAT, j as getCurrentGitTag, jt as execCommand, k as getLatestGitTag, kt as formatFile, lt as createGitCommit, m as buildChangelog, mt as resolveVersionQualifier, n as printReleaseReportAnnotation, nt as getParsedGitCommit, o as HookManager, ot as parseGitCommit, p as buildReleaseNotes, pt as packageContainsCommit, q as GIT_REL_FLAGS, qt as bumpVersion, r as printReleaseReport, rt as GIT_PRETTY_FIELD_SEPARATOR, s as HookPriority, st as TTLCache, t as executeReleaseWorkflow, tt as getCurrentGitCommit, u as writeChangelog, ut as getCurrentGitBranch, v as resolvePackageStableTag, vt as isSemVer, w as extractSemVer, wt as isMatch, x as verifyPackageTag, xt as writeJson, y as filterPackages, yt as findReleaseRule, z as pushGitChanges, zt as RELEASE_HOOK_NAMES } from "./workflow-Dk-fKaAx.js";
2
2
  import { t as formatError } from "./formatError-BMsun8Wi.js";
3
3
  import { createRequire } from "node:module";
4
4
  import path from "node:path";
@@ -2384,7 +2384,7 @@ async function writeChangelog(cwd, plan) {
2384
2384
  }
2385
2385
  }
2386
2386
  // package.json
2387
- var version = "0.9.1";
2387
+ var version = "0.10.0";
2388
2388
  // src/workflow/commit/generateReleaseCommitMessage.ts
2389
2389
  var NOTABLE_TYPES = [
2390
2390
  "feat",
@@ -2466,6 +2466,16 @@ var HookPriority = {
2466
2466
  */
2467
2467
  var HookManager = class {
2468
2468
  #registry = /* @__PURE__ */ new Map();
2469
+ #middleware;
2470
+ /**
2471
+ * Create a hook manager.
2472
+ *
2473
+ * @param middleware Wrapper invoked in place of every registered handler
2474
+ * during emission
2475
+ */
2476
+ constructor(middleware) {
2477
+ this.#middleware = middleware;
2478
+ }
2469
2479
  /**
2470
2480
  * Register a handler function for a specific hook.
2471
2481
  *
@@ -2503,9 +2513,10 @@ var HookManager = class {
2503
2513
  /**
2504
2514
  * Trigger execution of all handlers registered to a hook.
2505
2515
  *
2506
- * Passes `context` through the handler pipeline in descending priority order.
2507
- * Enables handlers to control execution flow using `next` and executes `done`
2508
- * after the last handler completes.
2516
+ * Passes `context` through the handler pipeline in descending priority order
2517
+ * and dispatches each registration through the constructor middleware when
2518
+ * one is provided. Enables handlers to control execution flow using `next`
2519
+ * and executes `done` after the last handler completes.
2509
2520
  *
2510
2521
  * @param name Name of the hook to trigger
2511
2522
  * @param context Shared payload passed into each handler
@@ -2514,15 +2525,17 @@ var HookManager = class {
2514
2525
  */
2515
2526
  async emit(name, context, done) {
2516
2527
  const registrations = this.#registry.get(name) ?? [];
2528
+ const middleware = this.#middleware;
2517
2529
  const dispatch = async (index, context) => {
2518
2530
  const registration = registrations[index];
2519
2531
  if (!registration) return done ? await done(context) : void 0;
2520
2532
  let isNextCalled = false;
2521
- return await registration.handler(context, async (context) => {
2533
+ const next = async (context) => {
2522
2534
  if (isNextCalled) return;
2523
2535
  isNextCalled = true;
2524
2536
  return await dispatch(index + 1, context);
2525
- });
2537
+ };
2538
+ return await (middleware ? (context, next) => middleware(context, registration, next) : registration.handler)(context, next);
2526
2539
  };
2527
2540
  return await dispatch(0, context);
2528
2541
  }
@@ -2730,68 +2743,97 @@ function printReleaseReportAnnotation(env, stdout, report) {
2730
2743
  var formatAnnotationMessage = (message) => message.replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A");
2731
2744
  // src/workflow/executeReleaseWorkflow.ts
2732
2745
  /**
2733
- * Register a plugin's hook handler on the workflow hook manager.
2746
+ * Resolve a plugin's hook entry into a normalized hook definition.
2734
2747
  *
2735
- * Normalizes the plugin's hook entry into a handler and priority, wraps the
2736
- * handler in shared timing and logging middleware, and registers it under
2737
- * the registration's hook name. When `onHandlerError` is provided, a thrown
2738
- * handler error is passed to it and the middleware chain continues so later
2739
- * handlers still run; without it the wrapper attributes the failure to the
2740
- * current hook and plugin on `context.outcome` before rethrowing.
2748
+ * Normalizes the plugin's hook entry — a bare handler function or a
2749
+ * `{ priority, handler }` definition — and wraps the handler in shared timing
2750
+ * and logging middleware. When the wrapped handler throws, the failure is
2751
+ * attributed to the current hook and plugin on `context.outcome` before
2752
+ * rethrowing it. The `??=` assignment never overwrites a recorded outcome,
2753
+ * so `finalize` failures — which run after the outcome is recorded — leave it
2754
+ * unchanged.
2741
2755
  *
2742
- * @param manager Hook manager receiving the wrapped handler
2743
- * @param registration Plugin hook registration carrying the error strategy
2756
+ * @param hookName Name of the hook to resolve
2757
+ * @param plugin Plugin owning the hook entry
2758
+ * @returns Normalized hook definition, or `undefined` when the plugin does not
2759
+ * implement the hook
2744
2760
  */
2745
- function registerPluginHook(manager, registration) {
2746
- const { hookName, plugin } = registration;
2761
+ function resolvePluginHook(hookName, plugin) {
2747
2762
  let hook = plugin[hookName];
2748
2763
  if (typeof hook === "function") hook = { handler: hook };
2749
2764
  const handler = hook?.handler;
2750
2765
  const priority = hook?.priority;
2751
2766
  if (!handler) return;
2752
- manager.on(hookName, async (context, next) => {
2753
- const current = {
2754
- hook: hookName,
2755
- plugin: plugin.name
2756
- };
2757
- const label = `${colors.gray(`[${current.hook}]`)} ${current.plugin}`;
2758
- let startedLogging = false;
2759
- let hasError = false;
2760
- startedLogging = true;
2761
- context.logger.start(label);
2762
- const currentFrame = { startTime: performance.now() };
2763
- const nextFrame = { duration: 0 };
2764
- const runNext = async () => {
2765
- const startTime = performance.now();
2767
+ return {
2768
+ priority,
2769
+ handler: async (context, next) => {
2770
+ const current = {
2771
+ hook: hookName,
2772
+ plugin: plugin.name
2773
+ };
2774
+ const label = `${colors.gray(`[${current.hook}]`)} ${current.plugin}`;
2775
+ let startedLogging = false;
2776
+ let hasError = false;
2777
+ startedLogging = true;
2778
+ context.logger.start(label);
2779
+ const currentFrame = { startTime: performance.now() };
2780
+ const nextFrame = { duration: 0 };
2781
+ const runNext = async () => {
2782
+ const startTime = performance.now();
2783
+ try {
2784
+ return await next(context);
2785
+ } finally {
2786
+ nextFrame.duration = performance.now() - startTime;
2787
+ }
2788
+ };
2766
2789
  try {
2767
- return await next(context);
2790
+ return await handler.call(plugin, context, runNext);
2791
+ } catch (err) {
2792
+ hasError = true;
2793
+ context.outcome ??= {
2794
+ status: "failure",
2795
+ error: err,
2796
+ phase: current
2797
+ };
2798
+ throw err;
2768
2799
  } finally {
2769
- nextFrame.duration = performance.now() - startTime;
2800
+ if (startedLogging) {
2801
+ const duration = performance.now() - currentFrame.startTime - nextFrame.duration;
2802
+ const message = [label, (duration >= 5e3 ? colors.yellow : colors.cyan)(`${(duration / 1e3).toFixed(2)}s`)].join(" ");
2803
+ if (hasError) context.logger.error(message);
2804
+ else context.logger.success(message);
2805
+ }
2770
2806
  }
2771
- };
2807
+ }
2808
+ };
2809
+ }
2810
+ /**
2811
+ * Wrap a hook handler so a thrown error is recorded before rethrowing.
2812
+ *
2813
+ * Each recorded failure keeps the owning hook and plugin. The hook manager
2814
+ * middleware rescues rethrown `finalize` errors so the remaining
2815
+ * `finalize` handlers still run; other hook errors keep the fail-fast
2816
+ * unwinding behavior.
2817
+ *
2818
+ * @param handler Hook handler to wrap
2819
+ * @param hookName Name of the hook the handler is registered for
2820
+ * @param plugin Plugin owning the hook handler
2821
+ * @param failures Array of recorded handler failures
2822
+ * @returns Wrapped hook handler
2823
+ */
2824
+ function wrapHandlerWithFailureCollection(handler, hookName, plugin, failures) {
2825
+ return async (context, next) => {
2772
2826
  try {
2773
- return await handler.call(plugin, context, runNext);
2774
- } catch (err) {
2775
- hasError = true;
2776
- if (registration.onHandlerError) {
2777
- registration.onHandlerError(err);
2778
- return await runNext();
2779
- }
2780
- context.outcome ??= {
2781
- status: "failure",
2782
- error: err,
2783
- phase: current
2784
- };
2785
- throw err;
2786
- } finally {
2787
- if (startedLogging) {
2788
- const duration = performance.now() - currentFrame.startTime - nextFrame.duration;
2789
- const message = [label, (duration >= 5e3 ? colors.yellow : colors.cyan)(`${(duration / 1e3).toFixed(2)}s`)].join(" ");
2790
- if (hasError) context.logger.error(message);
2791
- else context.logger.success(message);
2792
- }
2827
+ return await handler(context, next);
2828
+ } catch (error) {
2829
+ failures.push({
2830
+ hook: hookName,
2831
+ plugin: plugin.name,
2832
+ error
2833
+ });
2834
+ throw error;
2793
2835
  }
2794
- }, priority);
2836
+ };
2795
2837
  }
2796
2838
  /**
2797
2839
  * Throw a cancellation error when the context abort signal has fired.
@@ -2820,9 +2862,10 @@ function throwIfCancelled(context) {
2820
2862
  * send notifications and clean up: when a phase hook throws, plugin rollbacks
2821
2863
  * run while the error unwinds, then every `finalize` handler runs with the
2822
2864
  * failure recorded on `context.outcome`. When a `finalize` handler throws,
2823
- * the remaining handlers still run and each failure is logged as a warning
2824
- * after the report. A failing `finalize` handler never changes the workflow
2825
- * outcome and never masks the original workflow error.
2865
+ * the hook manager middleware rescues the error so the remaining handlers
2866
+ * still run, and each `finalize` failure is logged as a warning after the
2867
+ * report. A failing `finalize` handler never changes the workflow outcome
2868
+ * and never masks the original workflow error.
2826
2869
  *
2827
2870
  * @param context Release execution context containing runtime options and logger
2828
2871
  * @param plugins List of release plugins to execute
@@ -2831,16 +2874,26 @@ function throwIfCancelled(context) {
2831
2874
  * @throws If a lifecycle hook fails or the workflow is cancelled
2832
2875
  */
2833
2876
  async function executeReleaseWorkflow(context, plugins) {
2834
- const phaseHookNames = RELEASE_HOOK_NAMES.filter((name) => name !== "finalize");
2835
2877
  context.outcome = null;
2836
- const manager = new HookManager();
2837
- for (const hookName of phaseHookNames) for (const plugin of plugins) registerPluginHook(manager, {
2838
- hookName,
2839
- plugin
2878
+ const handlerFailures = [];
2879
+ const manager = new HookManager(async (context, registration, next) => {
2880
+ if (registration.name !== "finalize") return registration.handler(context, next);
2881
+ try {
2882
+ return await registration.handler(context, next);
2883
+ } catch {
2884
+ return next(context);
2885
+ }
2840
2886
  });
2887
+ for (const hookName of RELEASE_HOOK_NAMES) for (const plugin of plugins) {
2888
+ const definition = resolvePluginHook(hookName, plugin);
2889
+ if (!definition) continue;
2890
+ const handler = wrapHandlerWithFailureCollection(definition.handler, hookName, plugin, handlerFailures);
2891
+ manager.on(hookName, handler, definition.priority);
2892
+ }
2841
2893
  const dispatch = async (index, context) => {
2842
- const hook = phaseHookNames[index];
2894
+ const hook = RELEASE_HOOK_NAMES[index];
2843
2895
  if (!hook) return;
2896
+ if (hook === "finalize") return await dispatch(index + 1, context);
2844
2897
  throwIfCancelled(context);
2845
2898
  return await manager.emit(hook, context, (context) => dispatch(index + 1, context));
2846
2899
  };
@@ -2858,21 +2911,13 @@ async function executeReleaseWorkflow(context, plugins) {
2858
2911
  phase: null
2859
2912
  };
2860
2913
  }
2861
- const finalizeFailures = [];
2862
- for (const plugin of plugins) registerPluginHook(manager, {
2863
- hookName: "finalize",
2864
- plugin,
2865
- onHandlerError: (error) => finalizeFailures.push({
2866
- plugin: plugin.name,
2867
- error
2868
- })
2869
- });
2870
2914
  await manager.emit("finalize", context);
2871
2915
  const report = generateReleaseReport(context);
2872
2916
  printReleaseReport(context.logger, report);
2873
2917
  appendReleaseReportSummary(context.logger, context.env, report);
2874
2918
  printReleaseReportAnnotation(context.env, context.stdout, report);
2875
- for (const failure of finalizeFailures) {
2919
+ for (const failure of handlerFailures) {
2920
+ if (failure.hook !== "finalize") continue;
2876
2921
  if (failure.error === context.outcome.error) continue;
2877
2922
  context.logger.warn(`Plugin "${failure.plugin}" could not finalize: ${failure.error instanceof Error ? failure.error.message : String(failure.error)}`);
2878
2923
  }
@@ -2880,4 +2925,4 @@ async function executeReleaseWorkflow(context, plugins) {
2880
2925
  }
2881
2926
  export { isGitShallowRepository as $, getGitTagMessage as A, execGit as At, getGitRemote as B, SEMVER_REGEX as Bt, iterateChangelogVersions as C, readJson as Ct, isGitTagExact as D, isTruthyString as Dt, buildDependencyGraph as E, isClass as Et, deleteGitTag as F, ALL_FILES as Ft, readGitHistory as G, pickPriorityReleaseType as Gt, getGitConfigValue as H, isStableVersion as Ht, createGitTag as I, DEFAULT_CHANGELOG_FILE as It, detectGitRelationship as J, extractVersionQualifier as Jt, mergeGitHistory as K, deriveCommitReleaseType as Kt, readGitFile as L, DEV_NULL as Lt, generateGitTagName as M, compact as Mt, ensureGitTag as N, isDefined as Nt, isGitTagConnected as O, interpolate as Ot, isGitTagPresent as P, buildTrailerPattern as Pt, withShallowLock as Q, resolveGitRepository as R, GIT_TRAILER_RELEASE_AGENT as Rt, extractLatestVersion as S, unique as St, extractPlainText as T, isGitHubActions as Tt, restoreFullGitHistory as U, isSameReleaseCycle as Ut, ensureGitUserConfig as V, promotePrereleaseVersions as Vt, readParsedGitHistory as W, deriveReleaseType as Wt, resolveGitRevision as X, expandGitHistory as Y, isGitAncestor as Z, resolvePackageTag as _, isSemVerGitTag as _t, appendReleaseReportSummary as a, parseGitPrettyFormat as at, discoverPackageTag as b, createPlugin as bt, generateReleaseCommitMessage as c, extractMentions as ct, prependChangelog as d, deriveTransitionReleases as dt, countGitHistory as et, extractPreviousVersion as f, deriveChangeReleases as ft, propagateDependencyUpdates as g, sanitizePrereleaseLabel as gt, readPackageHistory as h, resolveReleaseChannel as ht, generateReleaseReport as i, GIT_PRETTY_FORMAT as it, getCurrentGitTag as j, execCommand as jt, getLatestGitTag as k, formatFile as kt, version as l, createGitCommit as lt, buildChangelog as m, resolveVersionQualifier as mt, printReleaseReportAnnotation as n, getParsedGitCommit as nt, HookManager as o, parseGitCommit as ot, buildReleaseNotes as p, packageContainsCommit as pt, GIT_REL_FLAGS as q, bumpVersion as qt, printReleaseReport as r, GIT_PRETTY_FIELD_SEPARATOR as rt, HookPriority as s, TTLCache as st, executeReleaseWorkflow as t, getCurrentGitCommit as tt, writeChangelog as u, getCurrentGitBranch as ut, resolvePackageStableTag as v, isSemVer as vt, extractSemVer as w, isMatch as wt, verifyPackageTag as x, writeJson as xt, filterPackages as y, findReleaseRule as yt, pushGitChanges as z, RELEASE_HOOK_NAMES as zt };
2882
2927
 
2883
- //# sourceMappingURL=workflow-Z9WRyGi8.js.map
2928
+ //# sourceMappingURL=workflow-Dk-fKaAx.js.map