@reelout/core 0.6.0 → 0.8.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.
Files changed (49) hide show
  1. package/dist/analyzer.js +14 -10
  2. package/dist/analyzer.js.map +1 -1
  3. package/dist/builder.js +1 -1
  4. package/dist/changelog.js +1 -1
  5. package/dist/index.js +2 -51
  6. package/dist/index.js.map +1 -1
  7. package/dist/{workflow-c9uKSARL.js → workflow-MQRNVoZo.js} +765 -732
  8. package/dist/workflow-MQRNVoZo.js.map +1 -0
  9. package/package.json +1 -1
  10. package/src/analyzer.ts +27 -17
  11. package/src/config/const.ts +0 -2
  12. package/src/git/history/index.ts +2 -2
  13. package/src/git/history/{showGitHistory.ts → readGitHistory.ts} +3 -3
  14. package/src/git/history/{showParsedGitHistory.ts → readParsedGitHistory.ts} +6 -6
  15. package/src/git/tag/generateGitTagName.ts +1 -0
  16. package/src/git/tag/index.ts +1 -1
  17. package/src/git/tag/{isGitTagPointed.ts → isGitTagExact.ts} +1 -1
  18. package/src/util/index.ts +1 -0
  19. package/src/util/isGitHubActions.ts +18 -0
  20. package/src/workflow/analysis/deriveChangeReleases.ts +3 -3
  21. package/src/workflow/analysis/deriveTransitionReleases.ts +1 -1
  22. package/src/workflow/analysis/index.ts +1 -5
  23. package/src/workflow/analysis/{isCommitForPackage.ts → packageContainsCommit.ts} +4 -1
  24. package/src/workflow/analysis/readPackageHistory.ts +28 -9
  25. package/src/workflow/commit/index.ts +4 -0
  26. package/src/workflow/discovery/verifyPackageTag.ts +2 -2
  27. package/src/workflow/executeReleaseWorkflow.ts +11 -2
  28. package/src/workflow/index.ts +2 -2
  29. package/src/workflow/report/appendReleaseReportSummary.ts +115 -0
  30. package/src/workflow/report/index.ts +2 -0
  31. package/src/workflow/report/printReleaseReportAnnotation.ts +35 -0
  32. package/src/workflow/{versioning/determineReleaseType.ts → version/deriveCommitReleaseType.ts} +2 -2
  33. package/src/workflow/{versioning → version}/deriveReleaseType.ts +2 -2
  34. package/src/workflow/{versioning → version}/index.ts +2 -1
  35. package/dist/workflow-c9uKSARL.js.map +0 -1
  36. package/src/workflow/analysis/collectUnreleased.ts +0 -44
  37. package/src/workflow/analysis/sliceUnreleased.ts +0 -24
  38. package/src/workflow/analysis/sliceUnreleasedForPackage.ts +0 -41
  39. package/src/workflow/committing/formatReleaseFilterPatterns.ts +0 -18
  40. package/src/workflow/committing/index.ts +0 -7
  41. package/src/workflow/committing/isReleaseCommit.ts +0 -56
  42. package/src/workflow/committing/readReleaseFilterPatterns.ts +0 -38
  43. /package/src/workflow/{committing → commit}/generateReleaseCommitMessage.ts +0 -0
  44. /package/src/workflow/{versioning → version}/bumpVersion.ts +0 -0
  45. /package/src/workflow/{versioning → version}/extractVersionQualifier.ts +0 -0
  46. /package/src/workflow/{versioning → version}/isSameReleaseCycle.ts +0 -0
  47. /package/src/workflow/{versioning → version}/isStableVersion.ts +0 -0
  48. /package/src/workflow/{versioning → version}/pickPriorityReleaseType.ts +0 -0
  49. /package/src/workflow/{analysis → version}/promotePrereleaseVersions.ts +0 -0
@@ -11,6 +11,7 @@
11
11
  * @param name Package name (required for non-entry packages)
12
12
  * @param version Package version
13
13
  * @returns Tag string, or `null` when `version` is absent
14
+ * @throws If a non-entry package has no name
14
15
  */
15
16
  export function generateGitTagName(
16
17
  entry: boolean,
@@ -9,5 +9,5 @@ export * from './getCurrentGitTag'
9
9
  export * from './getGitTagMessage'
10
10
  export * from './getLatestGitTag'
11
11
  export * from './isGitTagConnected'
12
- export * from './isGitTagPointed'
12
+ export * from './isGitTagExact'
13
13
  export * from './isGitTagPresent'
@@ -11,7 +11,7 @@ import { execGit } from '#util'
11
11
  * @param commit Commit hash to compare against
12
12
  * @returns `true` when the tag points at `commit`, otherwise `false`
13
13
  */
14
- export async function isGitTagPointed(
14
+ export async function isGitTagExact(
15
15
  cwd: string,
16
16
  tag: string,
17
17
  commit: string
package/src/util/index.ts CHANGED
@@ -11,6 +11,7 @@ export * from './interpolate'
11
11
  export * from './isCI'
12
12
  export * from './isClass'
13
13
  export * from './isDefined'
14
+ export * from './isGitHubActions'
14
15
  export * from './isMatch'
15
16
  export * from './isQuietEnvironment'
16
17
  export * from './isTruthyString'
@@ -0,0 +1,18 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2026 Fai
3
+
4
+ import { isTruthyString } from './isTruthyString'
5
+
6
+ /**
7
+ * Determine whether the current process runs on a GitHub Actions runner.
8
+ *
9
+ * Checks if the `GITHUB_ACTIONS` environment variable is set to a truthy
10
+ * value. Gates GitHub Actions-specific reporting such as job summaries and
11
+ * annotations.
12
+ *
13
+ * @param env Readonly process environment variables object
14
+ * @returns `true` if `env.GITHUB_ACTIONS` normalizes to a truthy string, otherwise `false`
15
+ */
16
+ export function isGitHubActions(env: Readonly<NodeJS.ProcessEnv>): boolean {
17
+ return isTruthyString(env.GITHUB_ACTIONS)
18
+ }
@@ -7,8 +7,8 @@ import type {
7
7
  ReleasePlan,
8
8
  ReleaseTypeHint,
9
9
  } from '#types'
10
- import { deriveReleaseType, pickPriorityReleaseType } from '../versioning'
11
- import { isCommitForPackage } from './isCommitForPackage'
10
+ import { deriveReleaseType, pickPriorityReleaseType } from '../version'
11
+ import { packageContainsCommit } from './packageContainsCommit'
12
12
 
13
13
  /**
14
14
  * Analyze commit history to update release plans for packages.
@@ -34,7 +34,7 @@ export async function deriveChangeReleases(
34
34
  ): Promise<ReleasePlan[]> {
35
35
  for await (const commit of history) {
36
36
  plans = plans.map((plan): ReleasePlan => {
37
- if (!isCommitForPackage(plan.package, commit)) {
37
+ if (!packageContainsCommit(plan.package, commit)) {
38
38
  return plan
39
39
  }
40
40
 
@@ -8,7 +8,7 @@ import type {
8
8
  VersionTransition,
9
9
  } from '#types'
10
10
  import semver from 'semver'
11
- import { extractVersionQualifier } from '../versioning/extractVersionQualifier'
11
+ import { extractVersionQualifier } from '../version/extractVersionQualifier'
12
12
 
13
13
  /**
14
14
  * Derive transition release types for release plans based on version qualifiers.
@@ -1,12 +1,8 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright (c) 2026 Fai
3
3
 
4
- export * from './collectUnreleased'
5
4
  export * from './deriveChangeReleases'
6
5
  export * from './deriveTransitionReleases'
7
- export * from './isCommitForPackage'
8
- export * from './promotePrereleaseVersions'
6
+ export * from './packageContainsCommit'
9
7
  export * from './propagateDependencyUpdates'
10
8
  export * from './readPackageHistory'
11
- export * from './sliceUnreleased'
12
- export * from './sliceUnreleasedForPackage'
@@ -13,7 +13,10 @@ import path from 'node:path'
13
13
  * @param commit Parsed commit containing changed file paths
14
14
  * @returns `true` if any changed file matches the package pattern
15
15
  */
16
- export function isCommitForPackage(pkg: Package, commit: GitCommit): boolean {
16
+ export function packageContainsCommit(
17
+ pkg: Package,
18
+ commit: GitCommit
19
+ ): boolean {
17
20
  return commit.files.some((file) => {
18
21
  const { location } = pkg
19
22
  const files = pkg.files || path.join(location, ALL_FILES)
@@ -1,15 +1,26 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright (c) 2026 Fai
3
3
 
4
- import { showParsedGitHistory, type ShowGitHistoryOptions } from '#git'
4
+ import { readParsedGitHistory, type ReadGitHistoryOptions } from '#git'
5
5
  import type { GitCommit, Package } from '#types'
6
- import { isCommitForPackage } from './isCommitForPackage'
6
+ import { unique } from '#util'
7
+ import { packageContainsCommit } from './packageContainsCommit'
8
+
9
+ const LITERAL_PATH = /^[^*?[\]{}!+@]*$/
7
10
 
8
11
  /**
9
12
  * Yield commits from git history associated with a package.
10
13
  *
11
14
  * Filters git commit history to yield only entries relevant to the target
12
- * `pkg` directory.
15
+ * `pkg` directory. When the package file pattern is a list, plain file
16
+ * entries are added to the git path filter alongside the package directory
17
+ * (duplicates removed), so commits touching extra package files (for example
18
+ * the pnpm workspace manifest) are included. Only entries without glob or
19
+ * pattern metacharacters (wildcards, braces, and the extglob or negation
20
+ * characters used by package file patterns) are passed to git, because git
21
+ * pathspecs would interpret those characters differently. Pattern-like
22
+ * entries are left to `packageContainsCommit`, which matches them with the
23
+ * package's own file-pattern semantics.
13
24
  *
14
25
  * @param cwd Path to the working directory for git commands
15
26
  * @param pkg Package configuration containing the target directory
@@ -19,15 +30,23 @@ import { isCommitForPackage } from './isCommitForPackage'
19
30
  export async function* readPackageHistory(
20
31
  cwd: string,
21
32
  pkg: Package,
22
- options: ShowGitHistoryOptions = {}
33
+ options: ReadGitHistoryOptions = {}
23
34
  ): AsyncGenerator<GitCommit> {
24
- options = {
25
- ...options,
26
- filePath: options.filePath || pkg.location,
35
+ options = { ...options }
36
+
37
+ if (!options.filePath) {
38
+ if (Array.isArray(pkg.files)) {
39
+ options.filePath = unique([
40
+ pkg.location,
41
+ ...pkg.files.filter((file) => LITERAL_PATH.test(file)),
42
+ ])
43
+ } else {
44
+ options.filePath = pkg.location
45
+ }
27
46
  }
28
47
 
29
- for await (const commit of showParsedGitHistory(cwd, options)) {
30
- if (isCommitForPackage(pkg, commit)) {
48
+ for await (const commit of readParsedGitHistory(cwd, options)) {
49
+ if (packageContainsCommit(pkg, commit)) {
31
50
  yield commit
32
51
  }
33
52
  }
@@ -0,0 +1,4 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2026 Fai
3
+
4
+ export * from './generateReleaseCommitMessage'
@@ -8,7 +8,7 @@ import {
8
8
  isGitTagConnected,
9
9
  } from '#git'
10
10
  import type { GitCommit, Package } from '#types'
11
- import { isCommitForPackage } from '../analysis/isCommitForPackage'
11
+ import { packageContainsCommit } from '../analysis/packageContainsCommit'
12
12
 
13
13
  /**
14
14
  * Verify a Git tag against package specifications and repository history.
@@ -39,7 +39,7 @@ export async function verifyPackageTag(
39
39
  return false
40
40
  }
41
41
 
42
- if (!isCommitForPackage(pkg, tagCommit)) {
42
+ if (!packageContainsCommit(pkg, tagCommit)) {
43
43
  return false
44
44
  }
45
45
 
@@ -5,7 +5,12 @@ import { RELEASE_HOOK_NAMES } from '#config'
5
5
  import { HookManager, type HookHandler } from '#plugin'
6
6
  import type { ReleaseContext, ReleaseHookName, ReleasePlugin } from '#types'
7
7
  import { colors } from 'consola/utils'
8
- import { generateReleaseReport, printReleaseReport } from './report'
8
+ import {
9
+ appendReleaseReportSummary,
10
+ generateReleaseReport,
11
+ printReleaseReport,
12
+ printReleaseReportAnnotation,
13
+ } from './report'
9
14
 
10
15
  /**
11
16
  * Execute the complete release workflow across all configured plugins.
@@ -125,6 +130,10 @@ export async function executeReleaseWorkflow(
125
130
  context.error = err
126
131
  throw err
127
132
  } finally {
128
- printReleaseReport(context.logger, generateReleaseReport(context))
133
+ const report = generateReleaseReport(context)
134
+
135
+ printReleaseReport(context.logger, report)
136
+ appendReleaseReportSummary(context.logger, context.env, report)
137
+ printReleaseReportAnnotation(context.env, context.stdout, report)
129
138
  }
130
139
  }
@@ -3,8 +3,8 @@
3
3
 
4
4
  export * from './analysis'
5
5
  export * from './changelog'
6
- export * from './committing'
6
+ export * from './commit'
7
7
  export * from './discovery'
8
8
  export * from './executeReleaseWorkflow'
9
9
  export * from './report'
10
- export * from './versioning'
10
+ export * from './version'
@@ -0,0 +1,115 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2026 Fai
3
+
4
+ import type { ReleaseReport } from '#types'
5
+ import { isGitHubActions } from '#util'
6
+ import type { ConsolaInstance } from 'consola/core'
7
+ import { appendFileSync } from 'node:fs'
8
+
9
+ const STATUS_LABELS = {
10
+ success: 'Success',
11
+ failure: 'Failure',
12
+ } as const
13
+
14
+ type ReportPlan = ReleaseReport['plans'][number]
15
+
16
+ /**
17
+ * Append a Markdown release report to the GitHub Actions job summary.
18
+ *
19
+ * Detects a GitHub Actions runner through the `GITHUB_ACTIONS` environment
20
+ * variable and appends the rendered `report` to the file referenced by
21
+ * `GITHUB_STEP_SUMMARY`, so GitHub displays it on the run summary page. Does
22
+ * nothing outside GitHub Actions or when no summary file is configured, and
23
+ * logs a warning instead of throwing when the summary file cannot be written.
24
+ *
25
+ * @param logger Logger instance for reporting summary write failures
26
+ * @param env Readonly process environment variables object
27
+ * @param report Release report containing status and package details
28
+ */
29
+ export function appendReleaseReportSummary(
30
+ logger: ConsolaInstance,
31
+ env: Readonly<NodeJS.ProcessEnv>,
32
+ report: ReleaseReport
33
+ ): void {
34
+ if (!isGitHubActions(env)) return
35
+
36
+ const filePath = env.GITHUB_STEP_SUMMARY
37
+
38
+ if (!filePath) return
39
+
40
+ try {
41
+ appendFileSync(filePath, `\n${formatReleaseReportSummary(report)}`)
42
+ } catch (error) {
43
+ logger.warn(
44
+ `GitHub Actions job summary could not be written to "${filePath}": ${error instanceof Error ? error.message : error}`
45
+ )
46
+ }
47
+ }
48
+
49
+ const formatPackageLabel = (plan: ReportPlan): string => {
50
+ if (plan.package.name) return `\`${plan.package.name}\``
51
+
52
+ return `\`${plan.package.location}\``
53
+ }
54
+
55
+ const formatReleaseReportSummary = (report: ReleaseReport): string => {
56
+ const lines: string[] = ['## ReelOut Release Report', '']
57
+
58
+ if (report.status) {
59
+ lines.push(`**Status:** ${STATUS_LABELS[report.status]}`, '')
60
+ }
61
+
62
+ if (report.status === 'failure') {
63
+ const message =
64
+ report.error || 'An unexpected error occurred during the release process.'
65
+
66
+ lines.push(...message.split('\n').map((line) => `> ${line}`), '')
67
+
68
+ return lines.join('\n')
69
+ }
70
+
71
+ if (report.plans.length === 0) {
72
+ lines.push('No packages are scheduled for release.', '')
73
+
74
+ return lines.join('\n')
75
+ }
76
+
77
+ const plans = report.plans.toSorted((a, b) =>
78
+ (a.package.name || '').localeCompare(b.package.name || '')
79
+ )
80
+
81
+ lines.push('| Package | Version | Type | Tag |', '| --- | --- | --- | --- |')
82
+
83
+ for (const plan of plans) {
84
+ const version = `\`${plan.release.version}\` ← \`${plan.package.version}\``
85
+
86
+ lines.push(
87
+ [
88
+ `| ${formatPackageLabel(plan)}`,
89
+ version,
90
+ plan.release.type,
91
+ plan.release.tag ? `\`${plan.release.tag}\`` : '',
92
+ ].join(' | ') + ' |'
93
+ )
94
+ }
95
+
96
+ lines.push('')
97
+
98
+ for (const plan of plans) {
99
+ const changelog = plan.release.changelog?.trim()
100
+
101
+ if (!changelog) continue
102
+
103
+ lines.push(
104
+ '<details>',
105
+ `<summary>${formatPackageLabel(plan)} ${plan.release.version}</summary>`,
106
+ '',
107
+ changelog,
108
+ '',
109
+ '</details>',
110
+ ''
111
+ )
112
+ }
113
+
114
+ return lines.join('\n')
115
+ }
@@ -1,5 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright (c) 2026 Fai
3
3
 
4
+ export * from './appendReleaseReportSummary'
4
5
  export * from './generateReleaseReport'
5
6
  export * from './printReleaseReport'
7
+ export * from './printReleaseReportAnnotation'
@@ -0,0 +1,35 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2026 Fai
3
+
4
+ import type { ReleaseReport } from '#types'
5
+ import { isGitHubActions } from '#util'
6
+
7
+ /**
8
+ * Print a GitHub Actions error annotation for a failed release.
9
+ *
10
+ * Detects a GitHub Actions runner through the `GITHUB_ACTIONS` environment
11
+ * variable and writes a `::error` workflow command carrying the failure
12
+ * reason to `stdout`, so GitHub surfaces the failure as an annotation on the
13
+ * run page. Does nothing outside GitHub Actions or when the release did not
14
+ * fail.
15
+ *
16
+ * @param env Readonly process environment variables object
17
+ * @param stdout Writable stream receiving the annotation command
18
+ * @param report Release report containing status and failure details
19
+ */
20
+ export function printReleaseReportAnnotation(
21
+ env: Readonly<NodeJS.ProcessEnv>,
22
+ stdout: NodeJS.WritableStream,
23
+ report: ReleaseReport
24
+ ): void {
25
+ if (!isGitHubActions(env) || report.status !== 'failure') return
26
+
27
+ const message = formatAnnotationMessage(
28
+ report.error || 'An unexpected error occurred during the release process.'
29
+ )
30
+
31
+ stdout.write(`::error title=Release failed::${message}\n`)
32
+ }
33
+
34
+ const formatAnnotationMessage = (message: string): string =>
35
+ message.replaceAll('%', '%25').replaceAll('\r', '%0D').replaceAll('\n', '%0A')
@@ -5,7 +5,7 @@ import type { CommitClassifier, GitCommit, ReleaseType } from '#types'
5
5
  import semver from 'semver'
6
6
 
7
7
  /**
8
- * Determine the release type for a single commit.
8
+ * Derive the release type for a single commit.
9
9
  *
10
10
  * Returns `'minor'` for a commit marked as a breaking change while the
11
11
  * supplied `version` is zero-major (`0.y.z`), and `'major'` otherwise, since
@@ -19,7 +19,7 @@ import semver from 'semver'
19
19
  * @param version Current package version used to adjust zero-major breaking releases
20
20
  * @returns `ReleaseType` string, or `null` when no matching rule applies
21
21
  */
22
- export function determineReleaseType(
22
+ export function deriveCommitReleaseType(
23
23
  classifier: CommitClassifier,
24
24
  commit: GitCommit,
25
25
  version?: string | null | undefined
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) 2026 Fai
3
3
 
4
4
  import type { CommitClassifier, ReleasePlan, ReleaseType } from '#types'
5
- import { determineReleaseType } from './determineReleaseType'
5
+ import { deriveCommitReleaseType } from './deriveCommitReleaseType'
6
6
  import { pickPriorityReleaseType } from './pickPriorityReleaseType'
7
7
 
8
8
  /**
@@ -27,7 +27,7 @@ export function deriveReleaseType(
27
27
  for (const commit of plan.history) {
28
28
  releaseType = pickPriorityReleaseType(
29
29
  releaseType,
30
- determineReleaseType(classifier, commit, plan.package.version)
30
+ deriveCommitReleaseType(classifier, commit, plan.package.version)
31
31
  )
32
32
  }
33
33
 
@@ -2,9 +2,10 @@
2
2
  // Copyright (c) 2026 Fai
3
3
 
4
4
  export * from './bumpVersion'
5
+ export * from './deriveCommitReleaseType'
5
6
  export * from './deriveReleaseType'
6
- export * from './determineReleaseType'
7
7
  export * from './extractVersionQualifier'
8
8
  export * from './isSameReleaseCycle'
9
9
  export * from './isStableVersion'
10
10
  export * from './pickPriorityReleaseType'
11
+ export * from './promotePrereleaseVersions'