@reelout/core 0.11.0 → 0.12.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/README.md +1 -1
- package/dist/analyzer.js +1 -1
- package/dist/builder.js +1 -1
- package/dist/changelog.js +3 -3
- package/dist/changelog.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/{workflow-Dk-fKaAx.js → workflow-WWJphdYg.js} +156 -148
- package/dist/workflow-WWJphdYg.js.map +1 -0
- package/package.json +1 -1
- package/src/changelog.ts +3 -3
- package/src/plugin/HookDispatcher.ts +204 -0
- package/src/plugin/index.ts +1 -1
- package/src/types.ts +4 -4
- package/src/workflow/executeReleaseWorkflow.ts +132 -136
- package/dist/workflow-Dk-fKaAx.js.map +0 -1
- package/src/plugin/HookManager.ts +0 -166
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ This ESM-only package requires Node.js `>=24.15`.
|
|
|
17
17
|
Key exports:
|
|
18
18
|
|
|
19
19
|
- **Workflow** — `executeReleaseWorkflow(context, plugins)` runs the release workflow.
|
|
20
|
-
- **Plugin system** — `
|
|
20
|
+
- **Plugin system** — `HookDispatcher`, `Priority`, `RELEASE_HOOK_NAMES`, `createPlugin`, `resolvePlugin`.
|
|
21
21
|
- **Built-in plugins** — default exports from `@reelout/core/analyzer`, `@reelout/core/builder`, and `@reelout/core/changelog`.
|
|
22
22
|
- **Versioning** — `bumpVersion`, `generateGitTagName`, `generateReleaseCommitMessage`, `buildReleaseNotes`.
|
|
23
23
|
- **Git** — `parseGitCommit`, `pushGitChanges`, `restoreFullGitHistory`, and `ensureGitTag`.
|
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-
|
|
1
|
+
import { _ as resolvePackageTag, dt as deriveTransitionReleases, ft as deriveChangeReleases, g as propagateDependencyUpdates, h as readPackageHistory, l as version } from "./workflow-WWJphdYg.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-
|
|
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-WWJphdYg.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
|
|
1
|
+
import { _ as resolvePackageTag, b as discoverPackageTag, l as version, m as buildChangelog, s as Priority, u as writeChangelog } from "./workflow-WWJphdYg.js";
|
|
2
2
|
import { t as formatError } from "./formatError-BMsun8Wi.js";
|
|
3
3
|
import { colors } from "consola/utils";
|
|
4
4
|
// src/changelog.ts
|
|
@@ -17,8 +17,8 @@ var changelog = () => ({
|
|
|
17
17
|
name: "@reelout/core/changelog",
|
|
18
18
|
version,
|
|
19
19
|
discover: {
|
|
20
|
-
priority:
|
|
21
|
-
|
|
20
|
+
priority: Priority.Low,
|
|
21
|
+
middleware: async (context, next) => {
|
|
22
22
|
context.packages = await Promise.all(context.packages.map(async (pkg) => ({
|
|
23
23
|
...pkg,
|
|
24
24
|
tag: await resolvePackageTag(context.cwd, pkg)
|
package/dist/changelog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changelog.js","names":[],"sources":["../src/changelog.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport {
|
|
1
|
+
{"version":3,"file":"changelog.js","names":[],"sources":["../src/changelog.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { Priority } from '#plugin'\nimport type { Package, ReleasePlugin } from '#types'\nimport { formatError } from '#util'\nimport {\n buildChangelog,\n discoverPackageTag,\n resolvePackageTag,\n writeChangelog,\n} from '#workflow'\nimport { colors } from 'consola/utils'\nimport { version } from '../package.json'\n\n/**\n * Built-in plugin that resolves package tags, generates release changelogs, and persists changelog files.\n *\n * @remarks\n * **Lifecycle Stages:**\n * - `discover`: Resolves missing Git tags for workspace packages (low priority execution).\n * - `build`: Generates Markdown changelogs for planned releases based on historical commits.\n * - `write`: Writes generated changelog files to disk (skipped during dry-run mode).\n *\n * @returns A release plugin configured for changelog generation and file persistence.\n */\nconst changelog = (): ReleasePlugin => ({\n name: '@reelout/core/changelog',\n version,\n discover: {\n priority: Priority.Low,\n middleware: async (context, next) => {\n context.packages = await Promise.all(\n context.packages.map(async (pkg): Promise<Package> => ({\n ...pkg,\n tag: await resolvePackageTag(context.cwd, pkg),\n }))\n )\n\n await next(context)\n },\n },\n build: async (context, next) => {\n context.plans = await Promise.all(\n context.plans.map(async (plan) => {\n plan = { ...plan }\n\n if (!plan.release) {\n return plan\n }\n\n if (!plan.release.version) {\n return plan\n }\n\n plan.release = { ...plan.release }\n\n let changelog: string | null | undefined\n\n let previousTag = (await resolvePackageTag(context.cwd, plan.package))\n ?.name\n\n if (!previousTag) {\n previousTag = (await discoverPackageTag(context.cwd, plan.package))\n ?.name\n }\n\n try {\n changelog = await buildChangelog(context, plan.history, {\n packageDir: plan.package.location,\n changelogFile: plan.package.changelogFile,\n version: plan.release.version,\n previousTag,\n currentTag: plan.release.tag?.name,\n })\n } catch (err) {\n context.logger.warn(\n colors.yellow(\n `Changelog could not be generated for package at \"${colors.bold(plan.package.location)}\": ${formatError(err)}`\n )\n )\n }\n\n if (changelog) {\n plan.release.changelog = changelog\n }\n\n return plan\n })\n )\n\n return next(context)\n },\n write: async (context, next) => {\n if (context.dryRun) {\n context.logger.debug('[DRY RUN] Changelog files will not be written.')\n } else {\n for (const plan of context.plans) {\n await writeChangelog(context.cwd, plan)\n }\n }\n\n return next(context)\n },\n})\n\nexport default changelog\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAM,mBAAkC;CACtC,MAAM;CACN;CACA,UAAU;EACR,UAAU,SAAS;EACnB,YAAY,OAAO,SAAS,SAAS;GACnC,QAAQ,WAAW,MAAM,QAAQ,IAC/B,QAAQ,SAAS,IAAI,OAAO,SAA2B;IACrD,GAAG;IACH,KAAK,MAAM,kBAAkB,QAAQ,KAAK,GAAG;GAC/C,EAAE,CACJ;GAEA,MAAM,KAAK,OAAO;EACpB;CACF;CACA,OAAO,OAAO,SAAS,SAAS;EAC9B,QAAQ,QAAQ,MAAM,QAAQ,IAC5B,QAAQ,MAAM,IAAI,OAAO,SAAS;GAChC,OAAO,EAAE,GAAG,KAAK;GAEjB,IAAI,CAAC,KAAK,SACR,OAAO;GAGT,IAAI,CAAC,KAAK,QAAQ,SAChB,OAAO;GAGT,KAAK,UAAU,EAAE,GAAG,KAAK,QAAQ;GAEjC,IAAI;GAEJ,IAAI,eAAe,MAAM,kBAAkB,QAAQ,KAAK,KAAK,OAAO,EAAA,EAChE;GAEJ,IAAI,CAAC,aACH,eAAe,MAAM,mBAAmB,QAAQ,KAAK,KAAK,OAAO,EAAA,EAC7D;GAGN,IAAI;IACF,YAAY,MAAM,eAAe,SAAS,KAAK,SAAS;KACtD,YAAY,KAAK,QAAQ;KACzB,eAAe,KAAK,QAAQ;KAC5B,SAAS,KAAK,QAAQ;KACtB;KACA,YAAY,KAAK,QAAQ,KAAK;IAChC,CAAC;GACH,SAAS,KAAK;IACZ,QAAQ,OAAO,KACb,OAAO,OACL,oDAAoD,OAAO,KAAK,KAAK,QAAQ,QAAQ,EAAE,KAAK,YAAY,GAAG,GAC7G,CACF;GACF;GAEA,IAAI,WACF,KAAK,QAAQ,YAAY;GAG3B,OAAO;EACT,CAAC,CACH;EAEA,OAAO,KAAK,OAAO;CACrB;CACA,OAAO,OAAO,SAAS,SAAS;EAC9B,IAAI,QAAQ,QACV,QAAQ,OAAO,MAAM,gDAAgD;OAErE,KAAK,MAAM,QAAQ,QAAQ,OACzB,MAAM,eAAe,QAAQ,KAAK,IAAI;EAI1C,OAAO,KAAK,OAAO;CACrB;AACF"}
|
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
|
|
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 HookDispatcher, 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 Priority, 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-WWJphdYg.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";
|
|
@@ -176,6 +176,6 @@ function sortPackages(packages) {
|
|
|
176
176
|
}
|
|
177
177
|
return packageNodes.toSorted((a, b) => b.level - a.level).map((node) => node.package);
|
|
178
178
|
}
|
|
179
|
-
export { ALL_FILES, DEFAULT_CHANGELOG_FILE, DEV_NULL, GIT_PRETTY_FIELD_SEPARATOR, GIT_PRETTY_FORMAT, GIT_REL_FLAGS, GIT_TRAILER_RELEASE_AGENT,
|
|
179
|
+
export { ALL_FILES, DEFAULT_CHANGELOG_FILE, DEV_NULL, GIT_PRETTY_FIELD_SEPARATOR, GIT_PRETTY_FORMAT, GIT_REL_FLAGS, GIT_TRAILER_RELEASE_AGENT, HookDispatcher, Priority, RELEASE_HOOK_NAMES, SEMVER_REGEX, TTLCache, appendReleaseReportSummary, buildChangelog, buildDependencyGraph, buildReleaseNotes, buildTrailerPattern, bumpVersion, compact, countGitHistory, createGitCommit, createGitTag, createPlugin, deleteGitTag, deriveChangeReleases, deriveCommitReleaseType, deriveReleaseType, deriveTransitionReleases, detectGitRelationship, discoverPackageTag, ensureGitTag, ensureGitUserConfig, execCommand, execGit, executeReleaseWorkflow, expandGitHistory, extractLatestVersion, extractMentions, extractPlainText, extractPreviousVersion, extractSemVer, extractVersionQualifier, filterPackages, findReleaseRule, formatError, formatFile, generateGitTagName, generateReleaseCommitMessage, generateReleaseReport, getCurrentGitBranch, getCurrentGitCommit, getCurrentGitTag, getGitConfigValue, getGitRemote, getGitTagMessage, getLatestGitTag, getParsedGitCommit, interpolate, isCI, isClass, isDefined, isGitAncestor, isGitHubActions, isGitShallowRepository, isGitTagConnected, isGitTagExact, isGitTagPresent, isMatch, isQuietEnvironment, isSameReleaseCycle, isSemVer, isSemVerGitTag, isStableVersion, isTruthyString, iterateChangelogVersions, mergeGitHistory, normalizeCommitFilter, normalizeReleaseRule, normalizeWorkspace, packageContainsCommit, parseGitCommit, parseGitPrettyFormat, pickPriorityReleaseType, prependChangelog, printReleaseReport, printReleaseReportAnnotation, promotePrereleaseVersions, propagateDependencyUpdates, pushGitChanges, readGitFile, readGitHistory, readJson, readPackageHistory, readParsedGitHistory, resolveGitRepository, resolveGitRevision, resolvePackageStableTag, resolvePackageTag, resolvePlugin, resolveReleaseChannel, resolveVersionQualifier, restoreFullGitHistory, sanitizePrereleaseLabel, sortPackages, unique, verifyPackageTag, withShallowLock, writeChangelog, writeJson };
|
|
180
180
|
|
|
181
181
|
//# sourceMappingURL=index.js.map
|
|
@@ -2384,7 +2384,7 @@ async function writeChangelog(cwd, plan) {
|
|
|
2384
2384
|
}
|
|
2385
2385
|
}
|
|
2386
2386
|
// package.json
|
|
2387
|
-
var version = "0.
|
|
2387
|
+
var version = "0.11.0";
|
|
2388
2388
|
// src/workflow/commit/generateReleaseCommitMessage.ts
|
|
2389
2389
|
var NOTABLE_TYPES = [
|
|
2390
2390
|
"feat",
|
|
@@ -2452,92 +2452,100 @@ async function generateReleaseCommitMessage(cwd, plans, trailers = {}) {
|
|
|
2452
2452
|
Object.entries(trailers).map(([key, value]) => key && value != null ? `${key}: ${value}` : "").filter(Boolean).join("\n")
|
|
2453
2453
|
].filter(Boolean).join("\n\n");
|
|
2454
2454
|
}
|
|
2455
|
-
// src/plugin/
|
|
2456
|
-
|
|
2455
|
+
// src/plugin/HookDispatcher.ts
|
|
2456
|
+
/**
|
|
2457
|
+
* Priority ranks that order middleware within a hook.
|
|
2458
|
+
*/
|
|
2459
|
+
var Priority = {
|
|
2457
2460
|
High: 50,
|
|
2458
2461
|
Normal: 0,
|
|
2459
2462
|
Low: -50
|
|
2460
2463
|
};
|
|
2461
2464
|
/**
|
|
2462
|
-
*
|
|
2465
|
+
* Dispatch registered hooks through asynchronous execution chains.
|
|
2463
2466
|
*
|
|
2464
|
-
* Stores
|
|
2465
|
-
* priority order.
|
|
2467
|
+
* Stores middleware in a prioritized registry and executes them sequentially
|
|
2468
|
+
* in priority order.
|
|
2466
2469
|
*/
|
|
2467
|
-
var
|
|
2470
|
+
var HookDispatcher = class {
|
|
2468
2471
|
#registry = /* @__PURE__ */ new Map();
|
|
2469
|
-
#
|
|
2472
|
+
#interceptor;
|
|
2470
2473
|
/**
|
|
2471
|
-
* Create a hook
|
|
2474
|
+
* Create a hook dispatcher.
|
|
2472
2475
|
*
|
|
2473
|
-
* @param
|
|
2474
|
-
* during
|
|
2476
|
+
* @param interceptor Wrapper invoked in place of every registered
|
|
2477
|
+
* middleware during dispatch
|
|
2475
2478
|
*/
|
|
2476
|
-
constructor(
|
|
2477
|
-
this.#
|
|
2479
|
+
constructor(interceptor) {
|
|
2480
|
+
this.#interceptor = interceptor;
|
|
2478
2481
|
}
|
|
2479
2482
|
/**
|
|
2480
|
-
* Register
|
|
2483
|
+
* Register middleware for a specific hook.
|
|
2481
2484
|
*
|
|
2482
|
-
* Adds the `
|
|
2483
|
-
* so higher-priority
|
|
2485
|
+
* Adds the `middleware` to the internal registry for `hook` and sorts the
|
|
2486
|
+
* list so higher-priority middleware runs first. An omitted or `undefined`
|
|
2487
|
+
* `options.priority` defaults to `Priority.Normal`; `options.meta` is
|
|
2488
|
+
* carried on the registration for the constructor interceptor.
|
|
2484
2489
|
*
|
|
2485
|
-
* @param
|
|
2486
|
-
* @param
|
|
2487
|
-
* @param
|
|
2490
|
+
* @param hook Name of the hook to register
|
|
2491
|
+
* @param middleware Function executed when the hook dispatches
|
|
2492
|
+
* @param options Registration options carrying the execution order rank and
|
|
2493
|
+
* the metadata exposed to the constructor interceptor
|
|
2488
2494
|
*/
|
|
2489
|
-
on(
|
|
2490
|
-
const registrations = this.#registry.get(
|
|
2495
|
+
on(hook, middleware, options) {
|
|
2496
|
+
const registrations = this.#registry.get(hook) ?? [];
|
|
2491
2497
|
registrations.push({
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
priority
|
|
2498
|
+
hook,
|
|
2499
|
+
middleware,
|
|
2500
|
+
priority: options?.priority ?? Priority.Normal,
|
|
2501
|
+
meta: options?.meta
|
|
2495
2502
|
});
|
|
2496
2503
|
registrations.sort((a, b) => b.priority - a.priority);
|
|
2497
|
-
this.#registry.set(
|
|
2504
|
+
this.#registry.set(hook, registrations);
|
|
2498
2505
|
}
|
|
2499
2506
|
/**
|
|
2500
|
-
* Unregister
|
|
2507
|
+
* Unregister middleware from a specific hook.
|
|
2501
2508
|
*
|
|
2502
|
-
* Removes matching `
|
|
2503
|
-
* `
|
|
2509
|
+
* Removes matching `middleware` references from the internal registry for
|
|
2510
|
+
* `hook`. Takes no action if `hook` has no registered middleware.
|
|
2504
2511
|
*
|
|
2505
|
-
* @param
|
|
2506
|
-
* @param
|
|
2512
|
+
* @param hook Name of the hook to unregister from
|
|
2513
|
+
* @param middleware Reference of the middleware function to remove
|
|
2507
2514
|
*/
|
|
2508
|
-
off(
|
|
2509
|
-
const registrations = this.#registry.get(
|
|
2515
|
+
off(hook, middleware) {
|
|
2516
|
+
const registrations = this.#registry.get(hook);
|
|
2510
2517
|
if (!registrations) return;
|
|
2511
|
-
this.#registry.set(
|
|
2518
|
+
this.#registry.set(hook, registrations.filter((registration) => registration.middleware !== middleware));
|
|
2512
2519
|
}
|
|
2513
2520
|
/**
|
|
2514
|
-
*
|
|
2521
|
+
* Dispatch all middleware registered to a hook.
|
|
2515
2522
|
*
|
|
2516
|
-
* Passes `context` through the
|
|
2517
|
-
* and dispatches each registration through the constructor
|
|
2518
|
-
* one is provided. Enables
|
|
2519
|
-
* and executes `done` after the last
|
|
2523
|
+
* Passes `context` through the middleware pipeline in descending priority
|
|
2524
|
+
* order and dispatches each registration through the constructor
|
|
2525
|
+
* interceptor when one is provided. Enables middleware to control
|
|
2526
|
+
* execution flow using `next` and executes `done` after the last
|
|
2527
|
+
* middleware completes.
|
|
2520
2528
|
*
|
|
2521
|
-
* @param
|
|
2522
|
-
* @param context Shared payload passed into each
|
|
2529
|
+
* @param hook Name of the hook to dispatch
|
|
2530
|
+
* @param context Shared payload passed into each middleware
|
|
2523
2531
|
* @param done Optional final callback run after the pipeline completes
|
|
2524
2532
|
* @returns Promise that resolves when execution completes
|
|
2525
2533
|
*/
|
|
2526
|
-
async
|
|
2527
|
-
const registrations = this.#registry.get(
|
|
2528
|
-
const
|
|
2529
|
-
const
|
|
2534
|
+
async dispatch(hook, context, done) {
|
|
2535
|
+
const registrations = this.#registry.get(hook) ?? [];
|
|
2536
|
+
const interceptor = this.#interceptor;
|
|
2537
|
+
const run = async (index, context) => {
|
|
2530
2538
|
const registration = registrations[index];
|
|
2531
2539
|
if (!registration) return done ? await done(context) : void 0;
|
|
2532
2540
|
let isNextCalled = false;
|
|
2533
2541
|
const next = async (context) => {
|
|
2534
2542
|
if (isNextCalled) return;
|
|
2535
2543
|
isNextCalled = true;
|
|
2536
|
-
return await
|
|
2544
|
+
return await run(index + 1, context);
|
|
2537
2545
|
};
|
|
2538
|
-
return await (
|
|
2546
|
+
return await (interceptor ? (context, next) => interceptor(context, registration, next) : registration.middleware)(context, next);
|
|
2539
2547
|
};
|
|
2540
|
-
return await
|
|
2548
|
+
return await run(0, context);
|
|
2541
2549
|
}
|
|
2542
2550
|
};
|
|
2543
2551
|
// src/workflow/report/resolveErrorMessage.ts
|
|
@@ -2745,94 +2753,22 @@ var formatAnnotationMessage = (message) => message.replaceAll("%", "%25").replac
|
|
|
2745
2753
|
/**
|
|
2746
2754
|
* Resolve a plugin's hook entry into a normalized hook definition.
|
|
2747
2755
|
*
|
|
2748
|
-
*
|
|
2749
|
-
*
|
|
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.
|
|
2756
|
+
* Accepts a bare middleware function or a `{ priority, middleware }`
|
|
2757
|
+
* definition and extracts its middleware and priority.
|
|
2755
2758
|
*
|
|
2756
2759
|
* @param hookName Name of the hook to resolve
|
|
2757
2760
|
* @param plugin Plugin owning the hook entry
|
|
2758
|
-
* @returns Normalized hook definition, or `undefined` when
|
|
2759
|
-
* implement the hook
|
|
2761
|
+
* @returns Normalized hook definition, or `undefined` when unimplemented
|
|
2760
2762
|
*/
|
|
2761
2763
|
function resolvePluginHook(hookName, plugin) {
|
|
2762
2764
|
let hook = plugin[hookName];
|
|
2763
|
-
if (typeof hook === "function") hook = {
|
|
2764
|
-
const
|
|
2765
|
+
if (typeof hook === "function") hook = { middleware: hook };
|
|
2766
|
+
const middleware = hook?.middleware;
|
|
2765
2767
|
const priority = hook?.priority;
|
|
2766
|
-
if (!
|
|
2768
|
+
if (!middleware) return;
|
|
2767
2769
|
return {
|
|
2768
2770
|
priority,
|
|
2769
|
-
|
|
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
|
-
};
|
|
2789
|
-
try {
|
|
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;
|
|
2799
|
-
} finally {
|
|
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
|
-
}
|
|
2806
|
-
}
|
|
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) => {
|
|
2826
|
-
try {
|
|
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;
|
|
2835
|
-
}
|
|
2771
|
+
middleware
|
|
2836
2772
|
};
|
|
2837
2773
|
}
|
|
2838
2774
|
/**
|
|
@@ -2854,48 +2790,120 @@ function throwIfCancelled(context) {
|
|
|
2854
2790
|
}
|
|
2855
2791
|
}
|
|
2856
2792
|
/**
|
|
2793
|
+
* Format a duration in milliseconds as a seconds string.
|
|
2794
|
+
*
|
|
2795
|
+
* @param duration Duration in milliseconds
|
|
2796
|
+
* @returns Duration formatted as seconds with two decimal places
|
|
2797
|
+
*/
|
|
2798
|
+
function formatDuration(duration) {
|
|
2799
|
+
return `${(duration / 1e3).toFixed(2)}s`;
|
|
2800
|
+
}
|
|
2801
|
+
/**
|
|
2802
|
+
* Pick the console color for a duration, highlighting slow middleware.
|
|
2803
|
+
*
|
|
2804
|
+
* @param duration Duration in milliseconds
|
|
2805
|
+
* @returns Color function that highlights durations of five seconds or more
|
|
2806
|
+
*/
|
|
2807
|
+
function durationColor(duration) {
|
|
2808
|
+
return duration >= 5e3 ? colors.yellow : colors.cyan;
|
|
2809
|
+
}
|
|
2810
|
+
/**
|
|
2811
|
+
* Format a hook and its owning plugin as a display label.
|
|
2812
|
+
*
|
|
2813
|
+
* @param hook Name of the hook
|
|
2814
|
+
* @param plugin Name of the plugin owning the hook
|
|
2815
|
+
* @returns Gray hook name followed by the plugin name
|
|
2816
|
+
*/
|
|
2817
|
+
function hookLabel(hook, plugin) {
|
|
2818
|
+
return `${colors.gray(`[${hook}]`)} ${plugin}`;
|
|
2819
|
+
}
|
|
2820
|
+
/**
|
|
2857
2821
|
* Execute the complete release workflow across all configured plugins.
|
|
2858
2822
|
*
|
|
2859
2823
|
* Runs each lifecycle phase sequentially, dispatching plugin hooks in onion
|
|
2860
2824
|
* order based on declared priority, and checks the abort signal before each
|
|
2861
|
-
* phase.
|
|
2862
|
-
*
|
|
2863
|
-
*
|
|
2864
|
-
*
|
|
2865
|
-
*
|
|
2866
|
-
*
|
|
2867
|
-
*
|
|
2868
|
-
*
|
|
2825
|
+
* phase. Each dispatched middleware runs through a single constructor
|
|
2826
|
+
* interceptor that also attributes failures to the owning hook and plugin,
|
|
2827
|
+
* collects middleware failures, and rescues `finalize` errors so the
|
|
2828
|
+
* remaining `finalize` middleware still runs. Outside `test` mode the
|
|
2829
|
+
* interceptor logs every middleware's exclusive duration — its wall-clock
|
|
2830
|
+
* time minus the time consumed by downstream middleware — on completion.
|
|
2831
|
+
* When a phase hook throws, plugin rollbacks run while the error unwinds,
|
|
2832
|
+
* then every `finalize` middleware runs with the failure recorded on
|
|
2833
|
+
* `context.outcome`. Each `finalize` failure is logged as a warning after
|
|
2834
|
+
* the report. A failing `finalize` middleware never changes the workflow
|
|
2835
|
+
* outcome and never masks the original workflow error.
|
|
2869
2836
|
*
|
|
2870
2837
|
* @param context Release execution context containing runtime options and logger
|
|
2871
2838
|
* @param plugins List of release plugins to execute
|
|
2872
|
-
* @returns Promise that resolves when all phases and `finalize`
|
|
2839
|
+
* @returns Promise that resolves when all phases and `finalize` middleware
|
|
2873
2840
|
* complete
|
|
2874
2841
|
* @throws If a lifecycle hook fails or the workflow is cancelled
|
|
2875
2842
|
*/
|
|
2876
2843
|
async function executeReleaseWorkflow(context, plugins) {
|
|
2877
2844
|
context.outcome = null;
|
|
2878
|
-
const
|
|
2879
|
-
const
|
|
2880
|
-
|
|
2845
|
+
const middlewareFailures = [];
|
|
2846
|
+
const dispatcher = new HookDispatcher(async (context, registration, next) => {
|
|
2847
|
+
const plugin = registration.meta;
|
|
2848
|
+
/* istanbul ignore next */
|
|
2849
|
+
if (!plugin) throw new Error(`Registration for hook "${registration.hook}" is missing plugin metadata.`);
|
|
2850
|
+
const hook = registration.hook;
|
|
2851
|
+
const label = hookLabel(hook, plugin.name);
|
|
2852
|
+
context.logger.start(label);
|
|
2853
|
+
const startedAt = performance.now();
|
|
2854
|
+
let downstreamDuration = 0;
|
|
2855
|
+
const runNext = async () => {
|
|
2856
|
+
const downstreamStart = performance.now();
|
|
2857
|
+
try {
|
|
2858
|
+
return await next(context);
|
|
2859
|
+
} finally {
|
|
2860
|
+
downstreamDuration += performance.now() - downstreamStart;
|
|
2861
|
+
}
|
|
2862
|
+
};
|
|
2863
|
+
const finish = (hasError) => {
|
|
2864
|
+
const duration = performance.now() - startedAt - downstreamDuration;
|
|
2865
|
+
const color = durationColor(duration);
|
|
2866
|
+
const message = [label, color(formatDuration(duration))].join(" ");
|
|
2867
|
+
if (hasError) context.logger.error(message);
|
|
2868
|
+
else context.logger.success(message);
|
|
2869
|
+
};
|
|
2881
2870
|
try {
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
return
|
|
2871
|
+
const result = await registration.middleware.call(plugin, context, runNext);
|
|
2872
|
+
finish(false);
|
|
2873
|
+
return result;
|
|
2874
|
+
} catch (error) {
|
|
2875
|
+
const phase = {
|
|
2876
|
+
hook,
|
|
2877
|
+
plugin: plugin.name
|
|
2878
|
+
};
|
|
2879
|
+
middlewareFailures.push({
|
|
2880
|
+
...phase,
|
|
2881
|
+
error
|
|
2882
|
+
});
|
|
2883
|
+
context.outcome ??= {
|
|
2884
|
+
status: "failure",
|
|
2885
|
+
error,
|
|
2886
|
+
phase
|
|
2887
|
+
};
|
|
2888
|
+
finish(true);
|
|
2889
|
+
if (hook === "finalize") return next(context);
|
|
2890
|
+
throw error;
|
|
2885
2891
|
}
|
|
2886
2892
|
});
|
|
2887
2893
|
for (const hookName of RELEASE_HOOK_NAMES) for (const plugin of plugins) {
|
|
2888
2894
|
const definition = resolvePluginHook(hookName, plugin);
|
|
2889
2895
|
if (!definition) continue;
|
|
2890
|
-
|
|
2891
|
-
|
|
2896
|
+
dispatcher.on(hookName, definition.middleware, {
|
|
2897
|
+
priority: definition.priority,
|
|
2898
|
+
meta: plugin
|
|
2899
|
+
});
|
|
2892
2900
|
}
|
|
2893
2901
|
const dispatch = async (index, context) => {
|
|
2894
2902
|
const hook = RELEASE_HOOK_NAMES[index];
|
|
2895
2903
|
if (!hook) return;
|
|
2896
2904
|
if (hook === "finalize") return await dispatch(index + 1, context);
|
|
2897
2905
|
throwIfCancelled(context);
|
|
2898
|
-
return await
|
|
2906
|
+
return await dispatcher.dispatch(hook, context, (context) => dispatch(index + 1, context));
|
|
2899
2907
|
};
|
|
2900
2908
|
try {
|
|
2901
2909
|
await dispatch(0, context);
|
|
@@ -2911,18 +2919,18 @@ async function executeReleaseWorkflow(context, plugins) {
|
|
|
2911
2919
|
phase: null
|
|
2912
2920
|
};
|
|
2913
2921
|
}
|
|
2914
|
-
await
|
|
2922
|
+
await dispatcher.dispatch("finalize", context);
|
|
2915
2923
|
const report = generateReleaseReport(context);
|
|
2916
2924
|
printReleaseReport(context.logger, report);
|
|
2917
2925
|
appendReleaseReportSummary(context.logger, context.env, report);
|
|
2918
2926
|
printReleaseReportAnnotation(context.env, context.stdout, report);
|
|
2919
|
-
for (const failure of
|
|
2927
|
+
for (const failure of middlewareFailures) {
|
|
2920
2928
|
if (failure.hook !== "finalize") continue;
|
|
2921
2929
|
if (failure.error === context.outcome.error) continue;
|
|
2922
2930
|
context.logger.warn(`Plugin "${failure.plugin}" could not finalize: ${failure.error instanceof Error ? failure.error.message : String(failure.error)}`);
|
|
2923
2931
|
}
|
|
2924
2932
|
if (context.outcome.status === "failure") throw context.outcome.error;
|
|
2925
2933
|
}
|
|
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,
|
|
2934
|
+
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, HookDispatcher 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, Priority 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 };
|
|
2927
2935
|
|
|
2928
|
-
//# sourceMappingURL=workflow-
|
|
2936
|
+
//# sourceMappingURL=workflow-WWJphdYg.js.map
|