@reelout/core 0.5.0 → 0.5.1
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 +35 -0
- package/dist/analyzer.js +2 -3
- package/dist/builder.js +3 -4
- package/dist/changelog.js +3 -4
- package/dist/{formatError-BXNdyRfu.js → formatError-BMsun8Wi.js} +2 -3
- package/dist/{formatError-BXNdyRfu.js.map → formatError-BMsun8Wi.js.map} +1 -1
- package/dist/index.js +11 -20
- package/dist/index.js.map +1 -1
- package/dist/{workflow-CroJ6v4g.js → workflow-DUIHrB5P.js} +91 -180
- package/dist/workflow-DUIHrB5P.js.map +1 -0
- package/package.json +8 -8
- package/dist/workflow-CroJ6v4g.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @reelout/core
|
|
2
|
+
|
|
3
|
+
Release engine for [ReelOut](https://github.com/reelout/reelout). This package
|
|
4
|
+
provides the plugin architecture, workflow executor, and shared Git,
|
|
5
|
+
versioning, and configuration utilities.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @reelout/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This ESM-only package requires Node.js `>=24.15`.
|
|
14
|
+
|
|
15
|
+
## API
|
|
16
|
+
|
|
17
|
+
Key exports:
|
|
18
|
+
|
|
19
|
+
- **Workflow** — `executeReleaseWorkflow(context, plugins)` runs the release workflow.
|
|
20
|
+
- **Plugin system** — `HookManager`, `HookPriority`, `RELEASE_HOOK_NAMES`, `createPlugin`, `resolvePlugin`.
|
|
21
|
+
- **Built-in plugins** — default exports from `@reelout/core/analyzer`, `@reelout/core/builder`, and `@reelout/core/changelog`.
|
|
22
|
+
- **Versioning** — `bumpVersion`, `generateGitTagName`, `generateReleaseCommitMessage`, `buildReleaseNotes`.
|
|
23
|
+
- **Git** — `parseGitCommit`, `pushGitChanges`, `restoreFullGitHistory`, and `ensureGitTag`.
|
|
24
|
+
- **Configuration helpers** — `normalizeReleaseRule`, `normalizeCommitFilter`.
|
|
25
|
+
- **Types** — `ReleaseConfig`, `ReleaseContext`, `ReleasePlugin`, `ReleasePlan`, `ReleaseRule`.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { executeReleaseWorkflow, type ReleasePlugin } from '@reelout/core'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Documentation
|
|
32
|
+
|
|
33
|
+
- [Plugins guide](https://github.com/reelout/reelout/blob/main/docs/04-plugins.md)
|
|
34
|
+
- [Programmatic API guide](https://github.com/reelout/reelout/blob/main/docs/05-api.md)
|
|
35
|
+
- [API reference](https://reelout.overview.vercel.app/)
|
package/dist/analyzer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { dt as deriveTransitionReleases, ft as deriveChangeReleases, g as propagateDependencyUpdates, m as sliceUnreleased, s as version } from "./workflow-
|
|
2
|
-
|
|
1
|
+
import { dt as deriveTransitionReleases, ft as deriveChangeReleases, g as propagateDependencyUpdates, m as sliceUnreleased, s as version } from "./workflow-DUIHrB5P.js";
|
|
2
|
+
// src/analyzer.ts
|
|
3
3
|
/**
|
|
4
4
|
* Built-in plugin that inspects repository history and produces release plans for packages.
|
|
5
5
|
*
|
|
@@ -27,7 +27,6 @@ var analyzer = () => ({
|
|
|
27
27
|
return next(context);
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
//#endregion
|
|
31
30
|
export { analyzer as default };
|
|
32
31
|
|
|
33
32
|
//# sourceMappingURL=analyzer.js.map
|
package/dist/builder.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Ut as bumpVersion, d as buildReleaseNotes, j as generateGitTagName, p as streamPackageCommits, s as version, v as resolvePackageStableTag, zt as isSameReleaseCycle } from "./workflow-
|
|
2
|
-
import { t as formatError } from "./formatError-
|
|
1
|
+
import { Ut as bumpVersion, d as buildReleaseNotes, j as generateGitTagName, p as streamPackageCommits, s as version, v as resolvePackageStableTag, zt as isSameReleaseCycle } from "./workflow-DUIHrB5P.js";
|
|
2
|
+
import { t as formatError } from "./formatError-BMsun8Wi.js";
|
|
3
3
|
import { colors } from "consola/utils";
|
|
4
|
-
|
|
4
|
+
// src/builder.ts
|
|
5
5
|
/**
|
|
6
6
|
* Built-in plugin that prepares release metadata and artifacts for active plans.
|
|
7
7
|
*
|
|
@@ -58,7 +58,6 @@ var builder = () => ({
|
|
|
58
58
|
return next(context);
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
|
-
//#endregion
|
|
62
61
|
export { builder as default };
|
|
63
62
|
|
|
64
63
|
//# sourceMappingURL=builder.js.map
|
package/dist/changelog.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as resolvePackageTag, a as HookPriority, c as writeChangelog, f as buildChangelog, s as version, y as discoverPackageTag } from "./workflow-
|
|
2
|
-
import { t as formatError } from "./formatError-
|
|
1
|
+
import { _ as resolvePackageTag, a as HookPriority, c as writeChangelog, f as buildChangelog, s as version, y as discoverPackageTag } from "./workflow-DUIHrB5P.js";
|
|
2
|
+
import { t as formatError } from "./formatError-BMsun8Wi.js";
|
|
3
3
|
import { colors } from "consola/utils";
|
|
4
|
-
|
|
4
|
+
// src/changelog.ts
|
|
5
5
|
/**
|
|
6
6
|
* Built-in plugin that resolves package tags, generates release changelogs, and persists changelog files.
|
|
7
7
|
*
|
|
@@ -57,7 +57,6 @@ var changelog = () => ({
|
|
|
57
57
|
return next(context);
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
-
//#endregion
|
|
61
60
|
export { changelog as default };
|
|
62
61
|
|
|
63
62
|
//# sourceMappingURL=changelog.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/util/formatError.ts
|
|
2
2
|
/**
|
|
3
3
|
* Normalize an unknown thrown value for logging or display.
|
|
4
4
|
*
|
|
@@ -17,7 +17,6 @@ function formatError(err) {
|
|
|
17
17
|
if (typeof err === "string") return err;
|
|
18
18
|
return err;
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
20
|
export { formatError as t };
|
|
22
21
|
|
|
23
|
-
//# sourceMappingURL=formatError-
|
|
22
|
+
//# sourceMappingURL=formatError-BMsun8Wi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatError-
|
|
1
|
+
{"version":3,"file":"formatError-BMsun8Wi.js","names":[],"sources":["../src/util/formatError.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Normalize an unknown thrown value for logging or display.\n *\n * - If `err` is an `Error`, returns its `message` string.\n * - Otherwise returns the original `err` value unchanged (may be a string,\n * object, number, `null`, or `undefined`).\n *\n * This function intentionally does not coerce non-Error values to strings so\n * callers can decide how to render structured values.\n *\n * @param err The thrown value to normalize\n * @returns The error message when `err` is an `Error`, otherwise the original value\n */\nexport function formatError<T>(err: T): T | string {\n if (Error.isError(err)) return err.message\n if (typeof err === 'string') return err\n return err\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,SAAgB,YAAe,KAAoB;CACjD,IAAI,MAAM,QAAQ,GAAG,GAAG,OAAO,IAAI;CACnC,IAAI,OAAO,QAAQ,UAAU,OAAO;CACpC,OAAO;AACT"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $ as countGitHistory, A as getCurrentGitTag, At as isDefined, B as ensureGitUserConfig, Bt as deriveReleaseType, C as extractSemVer, Ct as isMatch, D as isGitTagConnected, Dt as execGit, E as isGitTagPointed, Et as formatFile, F as createGitTag, Ft as GIT_TRAILER_RELEASE_AGENT, G as mergeGitHistory, H as showParsedGitHistory, Ht as determineReleaseType, I as readGitFile, It as RELEASE_HOOK_NAMES, J as expandGitHistory, K as GIT_REL_FLAGS, L as resolveGitRepository, Lt as SEMVER_REGEX, M as ensureGitTag, Mt as ALL_FILES, N as isGitTagPresent, Nt as DEFAULT_CHANGELOG_FILE, O as getLatestGitTag, Ot as execCommand, P as deleteGitTag, Pt as DEV_NULL, Q as isGitShallowRepository, R as pushGitChanges, Rt as isStableVersion, S as iterateChangelogVersions, St as readJson, T as buildDependencyGraph, Tt as interpolate, U as showGitHistory, Ut as bumpVersion, V as getGitConfigValue, Vt as pickPriorityReleaseType, W as restoreFullGitHistory, Wt as extractVersionQualifier, X as isGitAncestor, Y as resolveGitRevision, Z as withShallowLock, _ as resolvePackageTag, _t as isSemVerGitTag, a as HookPriority, at as parseGitCommit, b as verifyPackageTag, bt as createPlugin, c as writeChangelog, ct as createGitCommit, d as buildReleaseNotes, dt as deriveTransitionReleases, et as getCurrentGitCommit, f as buildChangelog, ft as deriveChangeReleases, g as propagateDependencyUpdates, gt as sanitizePrereleaseLabel, h as isReleaseCommit, ht as resolveReleaseChannel, i as HookManager, it as parseGitPrettyFormat, j as generateGitTagName, jt as buildTrailerPattern, k as getGitTagMessage, kt as compact, l as prependChangelog, lt as getCurrentGitBranch, m as sliceUnreleased, mt as resolveVersionQualifier, n as printReleaseReport, nt as GIT_PRETTY_FIELD_SEPARATOR, o as generateReleaseCommitMessage, ot as TTLCache, p as streamPackageCommits, pt as isCommitForPackage, q as detectGitRelationship, r as generateReleaseReport, rt as GIT_PRETTY_FORMAT, st as extractMentions, t as executeReleaseWorkflow, tt as getParsedGitCommit, u as extractPreviousVersion, ut as promotePrereleaseVersions, v as resolvePackageStableTag, vt as isSemVer, w as extractPlainText, wt as isClass, x as extractLatestVersion, xt as writeJson, y as discoverPackageTag, yt as findReleaseRule, z as getGitRemote, zt as isSameReleaseCycle } from "./workflow-
|
|
2
|
-
import { t as formatError } from "./formatError-
|
|
1
|
+
import { $ as countGitHistory, A as getCurrentGitTag, At as isDefined, B as ensureGitUserConfig, Bt as deriveReleaseType, C as extractSemVer, Ct as isMatch, D as isGitTagConnected, Dt as execGit, E as isGitTagPointed, Et as formatFile, F as createGitTag, Ft as GIT_TRAILER_RELEASE_AGENT, G as mergeGitHistory, H as showParsedGitHistory, Ht as determineReleaseType, I as readGitFile, It as RELEASE_HOOK_NAMES, J as expandGitHistory, K as GIT_REL_FLAGS, L as resolveGitRepository, Lt as SEMVER_REGEX, M as ensureGitTag, Mt as ALL_FILES, N as isGitTagPresent, Nt as DEFAULT_CHANGELOG_FILE, O as getLatestGitTag, Ot as execCommand, P as deleteGitTag, Pt as DEV_NULL, Q as isGitShallowRepository, R as pushGitChanges, Rt as isStableVersion, S as iterateChangelogVersions, St as readJson, T as buildDependencyGraph, Tt as interpolate, U as showGitHistory, Ut as bumpVersion, V as getGitConfigValue, Vt as pickPriorityReleaseType, W as restoreFullGitHistory, Wt as extractVersionQualifier, X as isGitAncestor, Y as resolveGitRevision, Z as withShallowLock, _ as resolvePackageTag, _t as isSemVerGitTag, a as HookPriority, at as parseGitCommit, b as verifyPackageTag, bt as createPlugin, c as writeChangelog, ct as createGitCommit, d as buildReleaseNotes, dt as deriveTransitionReleases, et as getCurrentGitCommit, f as buildChangelog, ft as deriveChangeReleases, g as propagateDependencyUpdates, gt as sanitizePrereleaseLabel, h as isReleaseCommit, ht as resolveReleaseChannel, i as HookManager, it as parseGitPrettyFormat, j as generateGitTagName, jt as buildTrailerPattern, k as getGitTagMessage, kt as compact, l as prependChangelog, lt as getCurrentGitBranch, m as sliceUnreleased, mt as resolveVersionQualifier, n as printReleaseReport, nt as GIT_PRETTY_FIELD_SEPARATOR, o as generateReleaseCommitMessage, ot as TTLCache, p as streamPackageCommits, pt as isCommitForPackage, q as detectGitRelationship, r as generateReleaseReport, rt as GIT_PRETTY_FORMAT, st as extractMentions, t as executeReleaseWorkflow, tt as getParsedGitCommit, u as extractPreviousVersion, ut as promotePrereleaseVersions, v as resolvePackageStableTag, vt as isSemVer, w as extractPlainText, wt as isClass, x as extractLatestVersion, xt as writeJson, y as discoverPackageTag, yt as findReleaseRule, z as getGitRemote, zt as isSameReleaseCycle } from "./workflow-DUIHrB5P.js";
|
|
2
|
+
import { t as formatError } from "./formatError-BMsun8Wi.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
|
-
|
|
6
|
+
// src/util/isTruthyString.ts
|
|
7
7
|
/**
|
|
8
8
|
* Determine whether a string value represents a truthy boolean.
|
|
9
9
|
*
|
|
@@ -18,8 +18,7 @@ function isTruthyString(value) {
|
|
|
18
18
|
const normalized = value.toLowerCase().trim();
|
|
19
19
|
return normalized === "true" || normalized === "1";
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
//#region src/util/isCI.ts
|
|
21
|
+
// src/util/isCI.ts
|
|
23
22
|
/**
|
|
24
23
|
* Determine whether the current process is running in a CI environment.
|
|
25
24
|
*
|
|
@@ -33,8 +32,7 @@ function isTruthyString(value) {
|
|
|
33
32
|
function isCI(env) {
|
|
34
33
|
return isTruthyString(env.CI);
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
//#region src/util/isQuietEnvironment.ts
|
|
35
|
+
// src/util/isQuietEnvironment.ts
|
|
38
36
|
/**
|
|
39
37
|
* Determine whether the current run should stay quiet about verbose output.
|
|
40
38
|
*
|
|
@@ -59,8 +57,7 @@ function isQuietEnvironment(context) {
|
|
|
59
57
|
if (isCI(context.env)) return false;
|
|
60
58
|
return context.stdout?.isTTY !== true;
|
|
61
59
|
}
|
|
62
|
-
|
|
63
|
-
//#region src/util/unique.ts
|
|
60
|
+
// src/util/unique.ts
|
|
64
61
|
/**
|
|
65
62
|
* Return a new array containing only the first-seen occurrence of each item.
|
|
66
63
|
*
|
|
@@ -80,8 +77,7 @@ function unique(array) {
|
|
|
80
77
|
}
|
|
81
78
|
return result;
|
|
82
79
|
}
|
|
83
|
-
|
|
84
|
-
//#region src/config/normalizeCommitFilter.ts
|
|
80
|
+
// src/config/normalizeCommitFilter.ts
|
|
85
81
|
/**
|
|
86
82
|
* Normalize a commit classifier into a consistent function.
|
|
87
83
|
*
|
|
@@ -100,8 +96,7 @@ function normalizeCommitFilter(classifier) {
|
|
|
100
96
|
}));
|
|
101
97
|
return (commit) => commit.type ? map.get(commit.type) : null;
|
|
102
98
|
}
|
|
103
|
-
|
|
104
|
-
//#region src/config/normalizeReleaseRule.ts
|
|
99
|
+
// src/config/normalizeReleaseRule.ts
|
|
105
100
|
/**
|
|
106
101
|
* Normalize a release rule input into a resolved release rule object.
|
|
107
102
|
*
|
|
@@ -139,8 +134,7 @@ function resolveRuleValue(value, pattern) {
|
|
|
139
134
|
if (typeof value === "string") return value;
|
|
140
135
|
if (value) return sanitizePrereleaseLabel(pattern);
|
|
141
136
|
}
|
|
142
|
-
|
|
143
|
-
//#region src/config/normalizeWorkspace.ts
|
|
137
|
+
// src/config/normalizeWorkspace.ts
|
|
144
138
|
/**
|
|
145
139
|
* Normalize and validate workspace configuration for a repository.
|
|
146
140
|
*
|
|
@@ -161,8 +155,7 @@ function normalizeWorkspace(cwd, workspace) {
|
|
|
161
155
|
members
|
|
162
156
|
};
|
|
163
157
|
}
|
|
164
|
-
|
|
165
|
-
//#region src/config/resolvePlugin.ts
|
|
158
|
+
// src/config/resolvePlugin.ts
|
|
166
159
|
/**
|
|
167
160
|
* Resolve a release plugin definition into a factory tuple or plugin object.
|
|
168
161
|
*
|
|
@@ -183,8 +176,7 @@ async function resolvePlugin(cwd, plugin) {
|
|
|
183
176
|
if (plugin != null && typeof plugin === "object" && Object.hasOwn(plugin, "name") && typeof plugin.name === "string") return plugin;
|
|
184
177
|
return null;
|
|
185
178
|
}
|
|
186
|
-
|
|
187
|
-
//#region src/workflow/discovery/sortPackages.ts
|
|
179
|
+
// src/workflow/discovery/sortPackages.ts
|
|
188
180
|
/**
|
|
189
181
|
* Sort workspace packages topologically based on their dependency graphs.
|
|
190
182
|
*
|
|
@@ -219,7 +211,6 @@ function sortPackages(packages) {
|
|
|
219
211
|
}
|
|
220
212
|
return packageNodes.toSorted((a, b) => b.level - a.level).map((node) => node.package);
|
|
221
213
|
}
|
|
222
|
-
//#endregion
|
|
223
214
|
export { ALL_FILES, DEFAULT_CHANGELOG_FILE, DEV_NULL, GIT_PRETTY_FIELD_SEPARATOR, GIT_PRETTY_FORMAT, GIT_REL_FLAGS, GIT_TRAILER_RELEASE_AGENT, HookManager, HookPriority, RELEASE_HOOK_NAMES, SEMVER_REGEX, TTLCache, buildChangelog, buildDependencyGraph, buildReleaseNotes, buildTrailerPattern, bumpVersion, compact, countGitHistory, createGitCommit, createGitTag, createPlugin, deleteGitTag, deriveChangeReleases, deriveReleaseType, deriveTransitionReleases, detectGitRelationship, determineReleaseType, discoverPackageTag, ensureGitTag, ensureGitUserConfig, execCommand, execGit, executeReleaseWorkflow, expandGitHistory, extractLatestVersion, extractMentions, extractPlainText, extractPreviousVersion, extractSemVer, extractVersionQualifier, findReleaseRule, formatError, formatFile, generateGitTagName, generateReleaseCommitMessage, generateReleaseReport, getCurrentGitBranch, getCurrentGitCommit, getCurrentGitTag, getGitConfigValue, getGitRemote, getGitTagMessage, getLatestGitTag, getParsedGitCommit, interpolate, isCI, isClass, isCommitForPackage, isDefined, isGitAncestor, isGitShallowRepository, isGitTagConnected, isGitTagPointed, isGitTagPresent, isMatch, isQuietEnvironment, isReleaseCommit, isSameReleaseCycle, isSemVer, isSemVerGitTag, isStableVersion, isTruthyString, iterateChangelogVersions, mergeGitHistory, normalizeCommitFilter, normalizeReleaseRule, normalizeWorkspace, parseGitCommit, parseGitPrettyFormat, pickPriorityReleaseType, prependChangelog, printReleaseReport, promotePrereleaseVersions, propagateDependencyUpdates, pushGitChanges, readGitFile, readJson, resolveGitRepository, resolveGitRevision, resolvePackageStableTag, resolvePackageTag, resolvePlugin, resolveReleaseChannel, resolveVersionQualifier, restoreFullGitHistory, sanitizePrereleaseLabel, showGitHistory, showParsedGitHistory, sliceUnreleased, sortPackages, streamPackageCommits, unique, verifyPackageTag, withShallowLock, writeChangelog, writeJson };
|
|
224
215
|
|
|
225
216
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/util/isTruthyString.ts","../src/util/isCI.ts","../src/util/isQuietEnvironment.ts","../src/util/unique.ts","../src/config/normalizeCommitFilter.ts","../src/config/normalizeReleaseRule.ts","../src/config/normalizeWorkspace.ts","../src/config/resolvePlugin.ts","../src/workflow/discovery/sortPackages.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Determine whether a string value represents a truthy boolean.\n *\n * Trims leading and trailing whitespace and coerces the target string to\n * lowercase. Evaluates the string as truthy if it equals `'true'` or `'1'`.\n *\n * @param value The raw string to evaluate\n * @returns `true` if `value` normalizes to `'true'` or `'1'`, otherwise `false`\n */\nexport function isTruthyString(value: string | undefined): boolean {\n if (!value) return false\n\n const normalized = value.toLowerCase().trim()\n\n return normalized === 'true' || normalized === '1'\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { isTruthyString } from './isTruthyString'\n\n/**\n * Determine whether the current process is running in a CI environment.\n *\n * Checks if the `CI` environment variable is set to a truthy value. Ignores\n * provider-specific variables such as `GITHUB_ACTIONS` to keep detection\n * generic.\n *\n * @param env Readonly process environment variables object\n * @returns `true` if `env.CI` normalizes to a truthy string, otherwise `false`\n */\nexport function isCI(env: Readonly<NodeJS.ProcessEnv>): boolean {\n return isTruthyString(env.CI)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseContext } from '../types'\nimport { isCI } from './isCI'\n\n/**\n * Determine whether the current run should stay quiet about verbose output.\n *\n * A run is quiet when nothing will keep what it prints: no terminal is attached\n * for a human, and no CI provider is recording a job log. A plain pipe outside\n * of CI — an agent sandbox, a script capturing output, a detached daemon — only\n * accumulates noise, so verbose output should be withheld and left to\n * `execCommand` for error reporting instead.\n *\n * CI is deliberately *not* quiet even though its streams are not TTYs: the\n * provider persists the job log, so the output does reach someone. A caller\n * that wants output from a pipe in a non-CI environment can set `CI=1` as an\n * escape hatch.\n *\n * The verdict is per environment, not per stream, so a redirected stdout inside\n * an interactive terminal still counts as quiet.\n *\n * @param context Release context carrying the destination stream and environment\n * @returns `true` when no TTY is attached and the run is not part of CI\n */\nexport function isQuietEnvironment(\n context: Pick<ReleaseContext, 'env' | 'stdout'>\n): boolean {\n if (isCI(context.env)) return false\n\n const stream = context.stdout as NodeJS.WriteStream | undefined\n\n return stream?.isTTY !== true\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Return a new array containing only the first-seen occurrence of each item.\n *\n * This preserves the original iteration order and performs equality checks\n * using JavaScript's `Set` semantics (i.e., primitives by value, objects by\n * reference). The input array is not mutated.\n *\n * @param array The array of items to deduplicate\n * @returns A new array with duplicates removed, preserving first-seen order\n */\nexport function unique<T>(array: readonly T[]): T[] {\n const seen = new Set<T>()\n const result: T[] = []\n\n for (const item of array) {\n if (!seen.has(item)) {\n seen.add(item)\n result.push(item)\n }\n }\n\n return result\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { CommitClassifier, ReleaseConfig, ReleaseType } from '#types'\n\n/**\n * Normalize a commit classifier into a consistent function.\n *\n * Accepts `null`/`undefined` (returns no-op classifier), a function classifier,\n * or a config object mapping commit types to release types. Returns a classifier\n * function that maps commits to their corresponding release types.\n *\n * @param classifier Commit classifier config, function, or falsy value\n * @returns Normalized classifier function\n */\nexport function normalizeCommitFilter(\n classifier: ReleaseConfig['classifier'] | null | undefined\n): CommitClassifier {\n if (classifier == null) {\n return () => null\n }\n\n if (typeof classifier === 'function') {\n return classifier\n }\n\n const map = new Map(\n Object.entries(classifier).flatMap(([releaseType, commitTypes]) => {\n return commitTypes.map((commitType) => [\n commitType,\n releaseType as ReleaseType,\n ])\n })\n )\n\n return (commit) => (commit.type ? map.get(commit.type) : null)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseRule, ResolvedReleaseRule } from '#types'\nimport { sanitizePrereleaseLabel } from './sanitizePrereleaseLabel'\n\n/**\n * Normalize a release rule input into a resolved release rule object.\n *\n * Converts `string` shorthand inputs into structured rule objects with sanitized\n * labels. Resolves `versionQualifier` and `releaseChannel` against `pattern`.\n * Returns `null` if `rule` is invalid, falsy, or missing `pattern`.\n *\n * @param rule Raw release rule input, `string` shorthand, or falsy value\n * @returns Resolved `ResolvedReleaseRule` object, or `null` if `rule` is invalid\n */\nexport function normalizeReleaseRule(\n rule: ReleaseRule | string | false | null | undefined\n): ResolvedReleaseRule | null {\n if (typeof rule === 'string') {\n rule = {\n pattern: rule,\n qualifier: sanitizePrereleaseLabel(rule),\n channel: sanitizePrereleaseLabel(rule),\n }\n }\n\n if (typeof rule !== 'object' || rule == null) {\n return null\n }\n\n const { pattern } = rule\n\n if (pattern == null) {\n return null\n }\n\n return {\n type: rule.type,\n pattern,\n versionQualifier: resolveRuleValue(rule.qualifier, pattern),\n releaseChannel: resolveRuleValue(rule.channel, pattern),\n }\n}\n\n/**\n * Resolve a rule property value from an explicit `string` or pattern fallback.\n *\n * @param value Explicit `string` value, `boolean` flag, or `undefined`\n * @param pattern Fallback pattern string used when `value` is `true`\n * @returns Resolved `string` value or `undefined`\n */\nfunction resolveRuleValue(\n value: string | boolean | undefined,\n pattern: string\n): string | undefined {\n if (typeof value === 'string') {\n return value\n }\n\n if (value) {\n return sanitizePrereleaseLabel(pattern)\n }\n\n return undefined\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { Workspace } from '#types'\nimport path from 'node:path'\n\n/**\n * Normalize and validate workspace configuration for a repository.\n *\n * Resolves the workspace entry directory relative to `cwd` and normalizes\n * the path representation. Returns a workspace object with normalized `entry`\n * and optional workspace members.\n *\n * @param cwd Repository working directory\n * @param workspace Partial workspace configuration (optional)\n * @returns Normalized workspace object\n */\nexport function normalizeWorkspace(\n cwd: string,\n workspace?: {\n entry?: string | null | undefined\n members?: readonly string[] | null | undefined\n }\n): Workspace {\n let entry = workspace?.entry || '.'\n const members = workspace?.members ?? null\n\n entry = path.normalize(path.relative(cwd, path.resolve(cwd, entry)))\n\n return {\n entry,\n members,\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type {\n ReleasePlugin,\n ReleasePluginDefinition,\n ReleasePluginFactory,\n ReleasePluginTuple,\n} from '#types'\nimport { createRequire } from 'node:module'\nimport { pathToFileURL } from 'node:url'\n\n/**\n * Resolve a release plugin definition into a factory tuple or plugin object.\n *\n * Handles string module specifiers by dynamically importing the package relative\n * to `cwd`. Unwraps ES module default exports, array configurations containing\n * options, function factories, and direct plugin objects.\n *\n * @param cwd The working directory path used to resolve string specifiers\n * @param plugin The plugin name, path, tuple configuration, or plugin object\n * @returns A factory tuple, plugin object, or null if resolution fails\n */\nexport async function resolvePlugin(\n cwd: string,\n plugin: unknown\n): Promise<ReleasePluginDefinition | ReleasePluginTuple | null> {\n let options: unknown\n\n if (Array.isArray(plugin)) {\n ;[plugin, options] = plugin\n }\n\n if (typeof plugin === 'string') {\n const require = createRequire(pathToFileURL(cwd))\n plugin = await import(require.resolve(plugin))\n }\n\n if (plugin != null && typeof plugin === 'object' && 'default' in plugin) {\n plugin = plugin.default\n }\n\n if (typeof plugin === 'function') {\n return [plugin as ReleasePluginFactory, options]\n }\n\n if (\n plugin != null &&\n typeof plugin === 'object' &&\n Object.hasOwn(plugin, 'name') &&\n typeof (plugin as ReleasePlugin).name === 'string'\n ) {\n return plugin as ReleasePlugin\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { Package } from '#types'\n\ninterface PackageNode {\n package: Package\n level: number\n}\n\n/**\n * Sort workspace packages topologically based on their dependency graphs.\n *\n * Deepest dependents are placed first in the resulting array, ensuring that\n * a package always precedes its own dependencies. Ties and circular dependencies\n * are resolved deterministically using an alphabetical sort on the package directory (`dir`).\n *\n * @param packages The workspace packages to sort.\n * @returns A new array of packages sorted by dependency depth and directory path.\n */\nexport function sortPackages(packages: readonly Package[]): Package[] {\n const packageNodes: PackageNode[] = []\n const packageMap = new Map<string, PackageNode>()\n\n for (const pkg of packages.toSorted((a, b) =>\n a.location.localeCompare(b.location)\n )) {\n const node: PackageNode = {\n package: pkg,\n level: -1,\n }\n\n packageNodes.push(node)\n\n if (pkg.name) {\n packageMap.set(pkg.name, node)\n }\n }\n\n for (const node of packageNodes) {\n visit(node)\n }\n\n function visit(\n node: PackageNode,\n level = 0,\n visited = new Set<PackageNode>()\n ): void {\n if (node.level >= level) {\n return\n }\n\n if (visited.has(node)) {\n return\n }\n\n visited.add(node)\n\n for (const depName of node.package.dependencies) {\n const depNode = packageMap.get(depName)\n\n if (depNode && depNode !== node) {\n visit(depNode, level + 1, visited)\n }\n }\n\n node.level = level\n }\n\n const sorted = packageNodes\n .toSorted((a, b) => b.level - a.level)\n .map((node) => node.package)\n\n return sorted\n}\n"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAgB,eAAe,OAAoC;CACjE,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,aAAa,MAAM,YAAY,CAAC,CAAC,KAAK;CAE5C,OAAO,eAAe,UAAU,eAAe;AACjD;;;;;;;;;;;;;ACHA,SAAgB,KAAK,KAA2C;CAC9D,OAAO,eAAe,IAAI,EAAE;AAC9B;;;;;;;;;;;;;;;;;;;;;;;ACSA,SAAgB,mBACd,SACS;CACT,IAAI,KAAK,QAAQ,GAAG,GAAG,OAAO;CAI9B,OAFe,QAAQ,QAER,UAAU;AAC3B;;;;;;;;;;;;;ACrBA,SAAgB,OAAU,OAA0B;CAClD,MAAM,uBAAO,IAAI,IAAO;CACxB,MAAM,SAAc,CAAC;CAErB,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG;EACnB,KAAK,IAAI,IAAI;EACb,OAAO,KAAK,IAAI;CAClB;CAGF,OAAO;AACT;;;;;;;;;;;;;ACVA,SAAgB,sB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AG9C,IAAI,UAAU,QAAQ,OAAO,WAAW,YAAY,aAAa,QAC/D,SAAS,OAAO;CAGlB,IAAI,OAAO,WAAW,YACpB,OAAO,CAAC,QAAgC,OAAO;CAGjD,IACE,UAAU,QACV,OAAO,WAAW,YAClB,OAAO,OAAO,QAAQ,MAAM,KAC5B,OAAQ,OAAyB,SAAS,UAE1C,OAAO;CAGT,OAAO;AACT;;;;;;;;;;;;;ACpCA,SAAgB,aAAa,UAAyC;CACpE,MAAM,eAA8B,CAAC;CACrC,MAAM,6BAAa,IAAI,IAAyB;CAEhD,KAAK,MAAM,OAAO,SAAS,UAAU,GAAG,MACtC,EAAE,SAAS,cAAc,EAAE,QAAQ,CACrC,GAAG;EACD,MAAM,OAAoB;GACxB,SAAS;GACT,OAAO;EACT;EAEA,aAAa,KAAK,IAAI;EAEtB,IAAI,IAAI,MACN,WAAW,IAAI,IAAI,MAAM,IAAI;CAEjC;CAEA,KAAK,MAAM,QAAQ,cACjB,MAAM,IAAI;CAGZ,SAAS,MACP,MACA,QAAQ,GACR,0BAAU,IAAI,IAAiB,GACzB;EACN,IAAI,KAAK,SAAS,OAChB;EAGF,IAAI,QAAQ,IAAI,IAAI,GAClB;EAGF,QAAQ,IAAI,IAAI;EAEhB,KAAK,MAAM,WAAW,KAAK,QAAQ,cAAc;GAC/C,MAAM,UAAU,WAAW,IAAI,OAAO;GAEtC,IAAI,WAAW,YAAY,MACzB,MAAM,SAAS,QAAQ,GAAG,OAAO;EAErC;EAEA,KAAK,QAAQ;CACf;CAMA,OAJe,aACZ,UAAU,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CACrC,KAAK,SAAS,KAAK,OAEf;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/util/isTruthyString.ts","../src/util/isCI.ts","../src/util/isQuietEnvironment.ts","../src/util/unique.ts","../src/config/normalizeCommitFilter.ts","../src/config/normalizeReleaseRule.ts","../src/config/normalizeWorkspace.ts","../src/config/resolvePlugin.ts","../src/workflow/discovery/sortPackages.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Determine whether a string value represents a truthy boolean.\n *\n * Trims leading and trailing whitespace and coerces the target string to\n * lowercase. Evaluates the string as truthy if it equals `'true'` or `'1'`.\n *\n * @param value The raw string to evaluate\n * @returns `true` if `value` normalizes to `'true'` or `'1'`, otherwise `false`\n */\nexport function isTruthyString(value: string | undefined): boolean {\n if (!value) return false\n\n const normalized = value.toLowerCase().trim()\n\n return normalized === 'true' || normalized === '1'\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { isTruthyString } from './isTruthyString'\n\n/**\n * Determine whether the current process is running in a CI environment.\n *\n * Checks if the `CI` environment variable is set to a truthy value. Ignores\n * provider-specific variables such as `GITHUB_ACTIONS` to keep detection\n * generic.\n *\n * @param env Readonly process environment variables object\n * @returns `true` if `env.CI` normalizes to a truthy string, otherwise `false`\n */\nexport function isCI(env: Readonly<NodeJS.ProcessEnv>): boolean {\n return isTruthyString(env.CI)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseContext } from '../types'\nimport { isCI } from './isCI'\n\n/**\n * Determine whether the current run should stay quiet about verbose output.\n *\n * A run is quiet when nothing will keep what it prints: no terminal is attached\n * for a human, and no CI provider is recording a job log. A plain pipe outside\n * of CI — an agent sandbox, a script capturing output, a detached daemon — only\n * accumulates noise, so verbose output should be withheld and left to\n * `execCommand` for error reporting instead.\n *\n * CI is deliberately *not* quiet even though its streams are not TTYs: the\n * provider persists the job log, so the output does reach someone. A caller\n * that wants output from a pipe in a non-CI environment can set `CI=1` as an\n * escape hatch.\n *\n * The verdict is per environment, not per stream, so a redirected stdout inside\n * an interactive terminal still counts as quiet.\n *\n * @param context Release context carrying the destination stream and environment\n * @returns `true` when no TTY is attached and the run is not part of CI\n */\nexport function isQuietEnvironment(\n context: Pick<ReleaseContext, 'env' | 'stdout'>\n): boolean {\n if (isCI(context.env)) return false\n\n const stream = context.stdout as NodeJS.WriteStream | undefined\n\n return stream?.isTTY !== true\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\n/**\n * Return a new array containing only the first-seen occurrence of each item.\n *\n * This preserves the original iteration order and performs equality checks\n * using JavaScript's `Set` semantics (i.e., primitives by value, objects by\n * reference). The input array is not mutated.\n *\n * @param array The array of items to deduplicate\n * @returns A new array with duplicates removed, preserving first-seen order\n */\nexport function unique<T>(array: readonly T[]): T[] {\n const seen = new Set<T>()\n const result: T[] = []\n\n for (const item of array) {\n if (!seen.has(item)) {\n seen.add(item)\n result.push(item)\n }\n }\n\n return result\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { CommitClassifier, ReleaseConfig, ReleaseType } from '#types'\n\n/**\n * Normalize a commit classifier into a consistent function.\n *\n * Accepts `null`/`undefined` (returns no-op classifier), a function classifier,\n * or a config object mapping commit types to release types. Returns a classifier\n * function that maps commits to their corresponding release types.\n *\n * @param classifier Commit classifier config, function, or falsy value\n * @returns Normalized classifier function\n */\nexport function normalizeCommitFilter(\n classifier: ReleaseConfig['classifier'] | null | undefined\n): CommitClassifier {\n if (classifier == null) {\n return () => null\n }\n\n if (typeof classifier === 'function') {\n return classifier\n }\n\n const map = new Map(\n Object.entries(classifier).flatMap(([releaseType, commitTypes]) => {\n return commitTypes.map((commitType) => [\n commitType,\n releaseType as ReleaseType,\n ])\n })\n )\n\n return (commit) => (commit.type ? map.get(commit.type) : null)\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseRule, ResolvedReleaseRule } from '#types'\nimport { sanitizePrereleaseLabel } from './sanitizePrereleaseLabel'\n\n/**\n * Normalize a release rule input into a resolved release rule object.\n *\n * Converts `string` shorthand inputs into structured rule objects with sanitized\n * labels. Resolves `versionQualifier` and `releaseChannel` against `pattern`.\n * Returns `null` if `rule` is invalid, falsy, or missing `pattern`.\n *\n * @param rule Raw release rule input, `string` shorthand, or falsy value\n * @returns Resolved `ResolvedReleaseRule` object, or `null` if `rule` is invalid\n */\nexport function normalizeReleaseRule(\n rule: ReleaseRule | string | false | null | undefined\n): ResolvedReleaseRule | null {\n if (typeof rule === 'string') {\n rule = {\n pattern: rule,\n qualifier: sanitizePrereleaseLabel(rule),\n channel: sanitizePrereleaseLabel(rule),\n }\n }\n\n if (typeof rule !== 'object' || rule == null) {\n return null\n }\n\n const { pattern } = rule\n\n if (pattern == null) {\n return null\n }\n\n return {\n type: rule.type,\n pattern,\n versionQualifier: resolveRuleValue(rule.qualifier, pattern),\n releaseChannel: resolveRuleValue(rule.channel, pattern),\n }\n}\n\n/**\n * Resolve a rule property value from an explicit `string` or pattern fallback.\n *\n * @param value Explicit `string` value, `boolean` flag, or `undefined`\n * @param pattern Fallback pattern string used when `value` is `true`\n * @returns Resolved `string` value or `undefined`\n */\nfunction resolveRuleValue(\n value: string | boolean | undefined,\n pattern: string\n): string | undefined {\n if (typeof value === 'string') {\n return value\n }\n\n if (value) {\n return sanitizePrereleaseLabel(pattern)\n }\n\n return undefined\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { Workspace } from '#types'\nimport path from 'node:path'\n\n/**\n * Normalize and validate workspace configuration for a repository.\n *\n * Resolves the workspace entry directory relative to `cwd` and normalizes\n * the path representation. Returns a workspace object with normalized `entry`\n * and optional workspace members.\n *\n * @param cwd Repository working directory\n * @param workspace Partial workspace configuration (optional)\n * @returns Normalized workspace object\n */\nexport function normalizeWorkspace(\n cwd: string,\n workspace?: {\n entry?: string | null | undefined\n members?: readonly string[] | null | undefined\n }\n): Workspace {\n let entry = workspace?.entry || '.'\n const members = workspace?.members ?? null\n\n entry = path.normalize(path.relative(cwd, path.resolve(cwd, entry)))\n\n return {\n entry,\n members,\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type {\n ReleasePlugin,\n ReleasePluginDefinition,\n ReleasePluginFactory,\n ReleasePluginTuple,\n} from '#types'\nimport { createRequire } from 'node:module'\nimport { pathToFileURL } from 'node:url'\n\n/**\n * Resolve a release plugin definition into a factory tuple or plugin object.\n *\n * Handles string module specifiers by dynamically importing the package relative\n * to `cwd`. Unwraps ES module default exports, array configurations containing\n * options, function factories, and direct plugin objects.\n *\n * @param cwd The working directory path used to resolve string specifiers\n * @param plugin The plugin name, path, tuple configuration, or plugin object\n * @returns A factory tuple, plugin object, or null if resolution fails\n */\nexport async function resolvePlugin(\n cwd: string,\n plugin: unknown\n): Promise<ReleasePluginDefinition | ReleasePluginTuple | null> {\n let options: unknown\n\n if (Array.isArray(plugin)) {\n ;[plugin, options] = plugin\n }\n\n if (typeof plugin === 'string') {\n const require = createRequire(pathToFileURL(cwd))\n plugin = await import(require.resolve(plugin))\n }\n\n if (plugin != null && typeof plugin === 'object' && 'default' in plugin) {\n plugin = plugin.default\n }\n\n if (typeof plugin === 'function') {\n return [plugin as ReleasePluginFactory, options]\n }\n\n if (\n plugin != null &&\n typeof plugin === 'object' &&\n Object.hasOwn(plugin, 'name') &&\n typeof (plugin as ReleasePlugin).name === 'string'\n ) {\n return plugin as ReleasePlugin\n }\n\n return null\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { Package } from '#types'\n\ninterface PackageNode {\n package: Package\n level: number\n}\n\n/**\n * Sort workspace packages topologically based on their dependency graphs.\n *\n * Deepest dependents are placed first in the resulting array, ensuring that\n * a package always precedes its own dependencies. Ties and circular dependencies\n * are resolved deterministically using an alphabetical sort on the package directory (`dir`).\n *\n * @param packages The workspace packages to sort.\n * @returns A new array of packages sorted by dependency depth and directory path.\n */\nexport function sortPackages(packages: readonly Package[]): Package[] {\n const packageNodes: PackageNode[] = []\n const packageMap = new Map<string, PackageNode>()\n\n for (const pkg of packages.toSorted((a, b) =>\n a.location.localeCompare(b.location)\n )) {\n const node: PackageNode = {\n package: pkg,\n level: -1,\n }\n\n packageNodes.push(node)\n\n if (pkg.name) {\n packageMap.set(pkg.name, node)\n }\n }\n\n for (const node of packageNodes) {\n visit(node)\n }\n\n function visit(\n node: PackageNode,\n level = 0,\n visited = new Set<PackageNode>()\n ): void {\n if (node.level >= level) {\n return\n }\n\n if (visited.has(node)) {\n return\n }\n\n visited.add(node)\n\n for (const depName of node.package.dependencies) {\n const depNode = packageMap.get(depName)\n\n if (depNode && depNode !== node) {\n visit(depNode, level + 1, visited)\n }\n }\n\n node.level = level\n }\n\n const sorted = packageNodes\n .toSorted((a, b) => b.level - a.level)\n .map((node) => node.package)\n\n return sorted\n}\n"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAgB,eAAe,OAAoC;CACjE,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,aAAa,MAAM,YAAY,CAAC,CAAC,KAAK;CAE5C,OAAO,eAAe,UAAU,eAAe;AACjD;;;;;;;;;;;;ACHA,SAAgB,KAAK,KAA2C;CAC9D,OAAO,eAAe,IAAI,EAAE;AAC9B;;;;;;;;;;;;;;;;;;;;;;ACSA,SAAgB,mBACd,SACS;CACT,IAAI,KAAK,QAAQ,GAAG,GAAG,OAAO;CAI9B,OAFe,QAAQ,QAER,UAAU;AAC3B;;;;;;;;;;;;ACrBA,SAAgB,OAAU,OAA0B;CAClD,MAAM,uBAAO,IAAI,IAAO;CACxB,MAAM,SAAc,CAAC;CAErB,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG;EACnB,KAAK,IAAI,IAAI;EACb,OAAO,KAAK,IAAI;CAClB;CAGF,OAAO;AACT;;;;;;;;;;;;ACVA,SAAgB,sBACd,YACkB;CAClB,IAAI,cAAc,MAChB,aAAa;CAGf,IAAI,OAAO,eAAe,YACxB,OAAO;CAGT,MAAM,MAAM,IAAI,IACd,OAAO,QAAQ,UAAU,CAAC,CAAC,SAAS,CAAC,aAAa,iBAAiB;EACjE,OAAO,YAAY,KAAK,eAAe,CACrC,YACA,WACF,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