@reelout/core 0.10.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-Z9WRyGi8.js → workflow-WWJphdYg.js} +177 -124
- 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 +5 -4
- package/src/workflow/executeReleaseWorkflow.ts +161 -136
- package/dist/workflow-Z9WRyGi8.js.map +0 -1
- package/src/plugin/HookManager.ts +0 -128
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,79 +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();
|
|
2472
|
+
#interceptor;
|
|
2473
|
+
/**
|
|
2474
|
+
* Create a hook dispatcher.
|
|
2475
|
+
*
|
|
2476
|
+
* @param interceptor Wrapper invoked in place of every registered
|
|
2477
|
+
* middleware during dispatch
|
|
2478
|
+
*/
|
|
2479
|
+
constructor(interceptor) {
|
|
2480
|
+
this.#interceptor = interceptor;
|
|
2481
|
+
}
|
|
2469
2482
|
/**
|
|
2470
|
-
* Register
|
|
2483
|
+
* Register middleware for a specific hook.
|
|
2471
2484
|
*
|
|
2472
|
-
* Adds the `
|
|
2473
|
-
* 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.
|
|
2474
2489
|
*
|
|
2475
|
-
* @param
|
|
2476
|
-
* @param
|
|
2477
|
-
* @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
|
|
2478
2494
|
*/
|
|
2479
|
-
on(
|
|
2480
|
-
const registrations = this.#registry.get(
|
|
2495
|
+
on(hook, middleware, options) {
|
|
2496
|
+
const registrations = this.#registry.get(hook) ?? [];
|
|
2481
2497
|
registrations.push({
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
priority
|
|
2498
|
+
hook,
|
|
2499
|
+
middleware,
|
|
2500
|
+
priority: options?.priority ?? Priority.Normal,
|
|
2501
|
+
meta: options?.meta
|
|
2485
2502
|
});
|
|
2486
2503
|
registrations.sort((a, b) => b.priority - a.priority);
|
|
2487
|
-
this.#registry.set(
|
|
2504
|
+
this.#registry.set(hook, registrations);
|
|
2488
2505
|
}
|
|
2489
2506
|
/**
|
|
2490
|
-
* Unregister
|
|
2507
|
+
* Unregister middleware from a specific hook.
|
|
2491
2508
|
*
|
|
2492
|
-
* Removes matching `
|
|
2493
|
-
* `
|
|
2509
|
+
* Removes matching `middleware` references from the internal registry for
|
|
2510
|
+
* `hook`. Takes no action if `hook` has no registered middleware.
|
|
2494
2511
|
*
|
|
2495
|
-
* @param
|
|
2496
|
-
* @param
|
|
2512
|
+
* @param hook Name of the hook to unregister from
|
|
2513
|
+
* @param middleware Reference of the middleware function to remove
|
|
2497
2514
|
*/
|
|
2498
|
-
off(
|
|
2499
|
-
const registrations = this.#registry.get(
|
|
2515
|
+
off(hook, middleware) {
|
|
2516
|
+
const registrations = this.#registry.get(hook);
|
|
2500
2517
|
if (!registrations) return;
|
|
2501
|
-
this.#registry.set(
|
|
2518
|
+
this.#registry.set(hook, registrations.filter((registration) => registration.middleware !== middleware));
|
|
2502
2519
|
}
|
|
2503
2520
|
/**
|
|
2504
|
-
*
|
|
2521
|
+
* Dispatch all middleware registered to a hook.
|
|
2505
2522
|
*
|
|
2506
|
-
* Passes `context` through the
|
|
2507
|
-
*
|
|
2508
|
-
*
|
|
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.
|
|
2509
2528
|
*
|
|
2510
|
-
* @param
|
|
2511
|
-
* @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
|
|
2512
2531
|
* @param done Optional final callback run after the pipeline completes
|
|
2513
2532
|
* @returns Promise that resolves when execution completes
|
|
2514
2533
|
*/
|
|
2515
|
-
async
|
|
2516
|
-
const registrations = this.#registry.get(
|
|
2517
|
-
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) => {
|
|
2518
2538
|
const registration = registrations[index];
|
|
2519
2539
|
if (!registration) return done ? await done(context) : void 0;
|
|
2520
2540
|
let isNextCalled = false;
|
|
2521
|
-
|
|
2541
|
+
const next = async (context) => {
|
|
2522
2542
|
if (isNextCalled) return;
|
|
2523
2543
|
isNextCalled = true;
|
|
2524
|
-
return await
|
|
2525
|
-
}
|
|
2544
|
+
return await run(index + 1, context);
|
|
2545
|
+
};
|
|
2546
|
+
return await (interceptor ? (context, next) => interceptor(context, registration, next) : registration.middleware)(context, next);
|
|
2526
2547
|
};
|
|
2527
|
-
return await
|
|
2548
|
+
return await run(0, context);
|
|
2528
2549
|
}
|
|
2529
2550
|
};
|
|
2530
2551
|
// src/workflow/report/resolveErrorMessage.ts
|
|
@@ -2730,68 +2751,25 @@ function printReleaseReportAnnotation(env, stdout, report) {
|
|
|
2730
2751
|
var formatAnnotationMessage = (message) => message.replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A");
|
|
2731
2752
|
// src/workflow/executeReleaseWorkflow.ts
|
|
2732
2753
|
/**
|
|
2733
|
-
*
|
|
2754
|
+
* Resolve a plugin's hook entry into a normalized hook definition.
|
|
2734
2755
|
*
|
|
2735
|
-
*
|
|
2736
|
-
*
|
|
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.
|
|
2756
|
+
* Accepts a bare middleware function or a `{ priority, middleware }`
|
|
2757
|
+
* definition and extracts its middleware and priority.
|
|
2741
2758
|
*
|
|
2742
|
-
* @param
|
|
2743
|
-
* @param
|
|
2759
|
+
* @param hookName Name of the hook to resolve
|
|
2760
|
+
* @param plugin Plugin owning the hook entry
|
|
2761
|
+
* @returns Normalized hook definition, or `undefined` when unimplemented
|
|
2744
2762
|
*/
|
|
2745
|
-
function
|
|
2746
|
-
const { hookName, plugin } = registration;
|
|
2763
|
+
function resolvePluginHook(hookName, plugin) {
|
|
2747
2764
|
let hook = plugin[hookName];
|
|
2748
|
-
if (typeof hook === "function") hook = {
|
|
2749
|
-
const
|
|
2765
|
+
if (typeof hook === "function") hook = { middleware: hook };
|
|
2766
|
+
const middleware = hook?.middleware;
|
|
2750
2767
|
const priority = hook?.priority;
|
|
2751
|
-
if (!
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
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();
|
|
2766
|
-
try {
|
|
2767
|
-
return await next(context);
|
|
2768
|
-
} finally {
|
|
2769
|
-
nextFrame.duration = performance.now() - startTime;
|
|
2770
|
-
}
|
|
2771
|
-
};
|
|
2772
|
-
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
|
-
}
|
|
2793
|
-
}
|
|
2794
|
-
}, priority);
|
|
2768
|
+
if (!middleware) return;
|
|
2769
|
+
return {
|
|
2770
|
+
priority,
|
|
2771
|
+
middleware
|
|
2772
|
+
};
|
|
2795
2773
|
}
|
|
2796
2774
|
/**
|
|
2797
2775
|
* Throw a cancellation error when the context abort signal has fired.
|
|
@@ -2812,37 +2790,120 @@ function throwIfCancelled(context) {
|
|
|
2812
2790
|
}
|
|
2813
2791
|
}
|
|
2814
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
|
+
/**
|
|
2815
2821
|
* Execute the complete release workflow across all configured plugins.
|
|
2816
2822
|
*
|
|
2817
2823
|
* Runs each lifecycle phase sequentially, dispatching plugin hooks in onion
|
|
2818
2824
|
* order based on declared priority, and checks the abort signal before each
|
|
2819
|
-
* phase.
|
|
2820
|
-
*
|
|
2821
|
-
*
|
|
2822
|
-
*
|
|
2823
|
-
*
|
|
2824
|
-
*
|
|
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
|
|
2825
2835
|
* outcome and never masks the original workflow error.
|
|
2826
2836
|
*
|
|
2827
2837
|
* @param context Release execution context containing runtime options and logger
|
|
2828
2838
|
* @param plugins List of release plugins to execute
|
|
2829
|
-
* @returns Promise that resolves when all phases and `finalize`
|
|
2839
|
+
* @returns Promise that resolves when all phases and `finalize` middleware
|
|
2830
2840
|
* complete
|
|
2831
2841
|
* @throws If a lifecycle hook fails or the workflow is cancelled
|
|
2832
2842
|
*/
|
|
2833
2843
|
async function executeReleaseWorkflow(context, plugins) {
|
|
2834
|
-
const phaseHookNames = RELEASE_HOOK_NAMES.filter((name) => name !== "finalize");
|
|
2835
2844
|
context.outcome = null;
|
|
2836
|
-
const
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
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
|
+
};
|
|
2870
|
+
try {
|
|
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;
|
|
2891
|
+
}
|
|
2840
2892
|
});
|
|
2893
|
+
for (const hookName of RELEASE_HOOK_NAMES) for (const plugin of plugins) {
|
|
2894
|
+
const definition = resolvePluginHook(hookName, plugin);
|
|
2895
|
+
if (!definition) continue;
|
|
2896
|
+
dispatcher.on(hookName, definition.middleware, {
|
|
2897
|
+
priority: definition.priority,
|
|
2898
|
+
meta: plugin
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2841
2901
|
const dispatch = async (index, context) => {
|
|
2842
|
-
const hook =
|
|
2902
|
+
const hook = RELEASE_HOOK_NAMES[index];
|
|
2843
2903
|
if (!hook) return;
|
|
2904
|
+
if (hook === "finalize") return await dispatch(index + 1, context);
|
|
2844
2905
|
throwIfCancelled(context);
|
|
2845
|
-
return await
|
|
2906
|
+
return await dispatcher.dispatch(hook, context, (context) => dispatch(index + 1, context));
|
|
2846
2907
|
};
|
|
2847
2908
|
try {
|
|
2848
2909
|
await dispatch(0, context);
|
|
@@ -2858,26 +2919,18 @@ async function executeReleaseWorkflow(context, plugins) {
|
|
|
2858
2919
|
phase: null
|
|
2859
2920
|
};
|
|
2860
2921
|
}
|
|
2861
|
-
|
|
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
|
-
await manager.emit("finalize", context);
|
|
2922
|
+
await dispatcher.dispatch("finalize", context);
|
|
2871
2923
|
const report = generateReleaseReport(context);
|
|
2872
2924
|
printReleaseReport(context.logger, report);
|
|
2873
2925
|
appendReleaseReportSummary(context.logger, context.env, report);
|
|
2874
2926
|
printReleaseReportAnnotation(context.env, context.stdout, report);
|
|
2875
|
-
for (const failure of
|
|
2927
|
+
for (const failure of middlewareFailures) {
|
|
2928
|
+
if (failure.hook !== "finalize") continue;
|
|
2876
2929
|
if (failure.error === context.outcome.error) continue;
|
|
2877
2930
|
context.logger.warn(`Plugin "${failure.plugin}" could not finalize: ${failure.error instanceof Error ? failure.error.message : String(failure.error)}`);
|
|
2878
2931
|
}
|
|
2879
2932
|
if (context.outcome.status === "failure") throw context.outcome.error;
|
|
2880
2933
|
}
|
|
2881
|
-
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 };
|
|
2882
2935
|
|
|
2883
|
-
//# sourceMappingURL=workflow-
|
|
2936
|
+
//# sourceMappingURL=workflow-WWJphdYg.js.map
|