Skip to content

cleanup#19

Merged
luxass merged 5 commits intomainfrom
cleanup
Mar 14, 2026
Merged

cleanup#19
luxass merged 5 commits intomainfrom
cleanup

Conversation

@luxass
Copy link
Member

@luxass luxass commented Mar 14, 2026

  • refactor: replace mri with node:util parseArgs and introduce ReleaseError
  • refactor: extract pure functions and fix console.warn
  • chore: remove unused code and unexport dead exports
  • test: add tests for errors, utils, version resolution, and commit filtering
  • docs: rewrite AGENTS.md to reflect current architecture

Summary by CodeRabbit

  • New Features

    • Added comprehensive error handling with helpful error hints and better-formatted messages
    • New exported utility functions for testing and extension purposes
  • Bug Fixes

    • Improved error reporting and boundary handling for release operations
    • Enhanced CLI flag parsing efficiency
  • Refactor

    • Modernized internal architecture for better maintainability and testability
    • Simplified public API surface
  • Chores

    • Removed unused dependency

luxass added 5 commits March 14, 2026 16:18
…rror

- Replace mri dependency with built-in node:util parseArgs for CLI flags
- Make CLI flags lazy via getter functions (getIsDryRun, getIsVerbose, getIsCI)
- Convert runIfNotDry from frozen const to dynamic function
- Remove module-level side-effect logging block
- Add ReleaseError class with printReleaseError for structured error output
- Make exitWithError throw ReleaseError instead of calling process.exit(1)
- Add withErrorBoundary at entry point to catch ReleaseError and exit
- Fix discoverWorkspacePackages to return err() instead of exitWithError
- Update isCI call sites to use getIsCI()
- Extract resolveAutoVersion from calculateVersionUpdates (pure, no IO)
- Extract computeDependencyRange from updateDependency (pure, no IO)
- Extract filterGlobalCommits from getGlobalCommitsPerPackage (pure, no IO)
- Wire extracted functions into production callers
- Export fileMatchesPackageFolder, isGlobalCommit, findCommitRange, DEPENDENCY_FILES
- Export getDependencyUpdates for internal use
- Fix console.warn to logger.warn in checkoutBranch
- Delete unused src/core/result-helpers.ts
- Remove @effect/language-service plugin from tsconfig.json
- Unexport dead functions: createPackageTag, pushTag, getPackageMetadata,
  formatCommitLine, dryRun, getDependencyUpdates
- Unexport dead types: CommitStatusState, CommitStatusOptions,
  UpsertPullRequestOptions, UpsertReleaseOptions, GitHubRelease,
  NPMError, NPMPackageMetadata, FormattedUnknownError,
  VersionOverride, VersionOverrides
- Remove unused GlobalCommitMode type and getIsForce function
…tering

- Add tests for formatUnknownError, ReleaseError, exitWithError, printReleaseError
- Add tests for getIsCI with various env configurations
- Add tests for resolveAutoVersion with commits, overrides, and edge cases
- Add tests for computeDependencyRange (workspace:*, peer deps, regular deps)
- Add tests for filterGlobalCommits, fileMatchesPackageFolder, isGlobalCommit,
  findCommitRange, and DEPENDENCY_FILES
- Fix test helper: add missing githubClient, access, combinePrereleaseIntoFirstStable
- Fix unresolved import in test/core/types.test.ts
Remove all Effect-TS references and document current architecture:
plain TypeScript with Result<T,E> pattern, ReleaseError thrown at
workflow level and caught at entry boundary, lazy CLI flags via
node:util parseArgs, and extracted pure testable functions.
@coderabbitai
Copy link

coderabbitai bot commented Mar 14, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Large-scale migration from Effect-TS architecture to plain TypeScript with Result-based error handling. Introduces pure, testable helper functions (resolveAutoVersion, computeDependencyRange, etc.), new ReleaseError class with centralized boundary handling, lazy CLI flag parsing via node:util, and reduces public API surface for internal types while expanding utilities for external testing.

Changes

Cohort / File(s) Summary
Error Handling & Entry Point
src/shared/errors.ts, src/index.ts
Introduced ReleaseError class and printReleaseError function; added withErrorBoundary wrapper for centralized error handling and controlled exit. Replaced direct process.exit semantics with ReleaseError throwing pattern.
Core Module Visibility
src/core/git.ts, src/core/github.ts, src/core/npm.ts, src/operations/changelog-format.ts
Reduced public API surface by making createPackageTag, pushTag, GitHubRelease, CommitStatusState, CommitStatusOptions, UpsertPullRequestOptions, UpsertReleaseOptions, NPMError, NPMPackageMetadata, getPackageMetadata, and formatCommitLine non-exported (internal). Added optional htmlUrl field to GitHubRelease.
Versioning & Commit Utilities
src/versioning/version.ts, src/versioning/commits.ts
Introduced pure, testable functions: resolveAutoVersion and computeDependencyRange exported from version.ts; fileMatchesPackageFolder, isGlobalCommit, findCommitRange, and filterGlobalCommits exported from commits.ts. Replaced inline logic with delegated helper calls; made VersionOverride and VersionOverrides non-exported.
CLI Parsing & Utils
src/shared/utils.ts, package.json
Replaced MRI-based parsing with lazy node:util parseArgs via getIsDryRun, getIsVerbose, and getIsCI getter functions; added parseCLIFlags helper and ucdjsReleaseOverridesPath constant. Made dryRun non-exported; updated runIfNotDry signature. Removed mri dependency.
Configuration & Cleanup
tsconfig.json, src/shared/types.ts, src/core/result-helpers.ts
Removed Effect language-service plugin from tsconfig.json. Removed exported GlobalCommitMode type. Removed public Result helper functions (map, mapAsync, mapErr, andThen, andThenAsync) from result-helpers.ts.
Workspace & Support
src/core/workspace.ts, test/_shared.ts
Updated workspace.ts to use getIsCI() instead of direct isCI export; changed error handling from process.exit to returning WorkspaceError. Extended test/_shared.ts NormalizedReleaseScriptsOptions with default githubClient, npm.access, and changelog configuration.
Architecture Documentation
AGENTS.md
Comprehensively updated documentation to reflect migration from Effect-TS service-oriented architecture to plain TypeScript with Result-based error handling, new module organization (src/core, src/operations, src/shared, src/versioning, src/workflows), and new public API surface.
Test Suite
test/core/types.test.ts, test/shared/errors.test.ts, test/shared/utils.test.ts, test/versioning/dependency-range.test.ts, test/versioning/global-commits.test.ts, test/versioning/package-graph.test.ts, test/versioning/resolve-version.test.ts, test/versioning/version-dependent-updates.test.ts
Added comprehensive test coverage for new utilities: error formatting and ReleaseError class, CLI flag detection (getIsCI), computeDependencyRange behavior, commit filtering and global commit detection, package dependency graph operations, resolveAutoVersion resolution logic, and dependent version update calculations.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI Entry<br/>(src/index.ts)
    participant Boundary as Error Boundary<br/>(withErrorBoundary)
    participant Ops as Release Operations<br/>(verify/prepare/publish)
    participant Core as Core Modules<br/>(git/npm/github)
    participant ErrorHandler as Error Handler<br/>(printReleaseError)

    CLI->>CLI: Parse CLI flags lazily<br/>(getIsDryRun, getIsVerbose, getIsCI)
    CLI->>Boundary: Wrap operation execution
    Boundary->>Ops: Execute release scripts
    Ops->>Core: Call core functions<br/>(may return Result or throw)
    alt Operation Success
        Core-->>Ops: Result.ok(value)
        Ops-->>Boundary: Complete successfully
        Boundary-->>CLI: Return control
    else Operation Fails
        Core-->>Ops: Result.err(error) or throw
        Ops-->>Boundary: ReleaseError thrown
        Boundary->>ErrorHandler: Catch ReleaseError
        ErrorHandler->>ErrorHandler: Format error with<br/>message, hint, cause, stack
        ErrorHandler-->>CLI: Print to stderr + exit
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~70 minutes

Possibly related PRs

  • refactor: rewrite in effect #15: Directly opposes this PR's migration from Effect-TS to plain TypeScript, reverting changes to a service-oriented Effect-based architecture.
  • feat(release): enhance dx #9: Overlaps on versioning utilities and commit handling with edits to src/versioning/commits.ts and src/versioning/version.ts.
  • refactor: improve workspace logic #6: Shares workspace discovery refactoring and CI flag handling pattern changes affecting isCI utility usage across modules.

Poem

🐰 Hops through architectures with glee,
From Effect-TS bonds now finally free,
Pure functions emerge, testable and clear,
Errors now bounded—no more runtime fear!
Results and helpers, a hop, skip, and bound,
The cleanest refactor this warren has found!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.30% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The pull request title 'cleanup' is vague and generic, lacking specific information about what aspect of the codebase is being cleaned up. Revise the title to be more descriptive, such as 'Replace mri with node:util parseArgs and introduce ReleaseError' or 'Extract pure functions and refactor error handling' to better communicate the main changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cleanup
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@luxass luxass requested a review from Copilot March 14, 2026 15:27
@luxass luxass merged commit 07f40b0 into main Mar 14, 2026
3 of 4 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR performs a broad cleanup/refactor of the release-scripts codebase: it removes mri in favor of node:util’s parseArgs, introduces a ReleaseError-based error flow, extracts/test-drives several pure versioning helpers, and updates documentation to reflect the current non-Effect architecture.

Changes:

  • Refactor CLI flag parsing (mriparseArgs) and adjust logging/dry-run behavior.
  • Introduce ReleaseError + entrypoint error boundary; refactor error handling paths to be testable.
  • Extract and add tests for pure versioning/commit-filtering helpers (dependency ranges, global commit filtering, dependent bumps).

Reviewed changes

Copilot reviewed 23 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tsconfig.json Removes TS language-service plugin config.
src/shared/utils.ts Replaces mri with parseArgs; makes CI/verbose/dry-run checks lazy getters.
src/shared/errors.ts Adds ReleaseError, printReleaseError, and changes exitWithError to throw.
src/index.ts Adds an error boundary to catch ReleaseError and exit consistently.
src/versioning/version.ts Extracts resolveAutoVersion and computeDependencyRange; refactors CI gating.
src/versioning/commits.ts Exports commit classification helpers and introduces filterGlobalCommits.
src/core/workspace.ts Switches missing-package handling from process-exit to Result error return.
src/core/git.ts Routes unexpected checkout output through logger.warn; unexports some helpers.
src/core/npm.ts Unexports internal types/helpers (e.g. getPackageMetadata).
src/core/github.ts Narrows exported surface by making several types internal.
src/operations/changelog-format.ts Makes formatCommitLine internal to the module.
src/core/result-helpers.ts Removes dead helper module.
src/shared/types.ts Removes dead GlobalCommitMode export.
test/** Adds coverage for errors/utils/version resolution/dependency ranges/global commits/package graph/dependent bumps.
AGENTS.md Rewrites documentation to match current architecture and module layout.
package.json / pnpm-lock.yaml Removes mri dependency.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const determinedBump = determineHighestBump(allCommits);
const effectiveBump = override?.type || determinedBump;
const autoVersion = getNextVersion(pkg.version, determinedBump);
const resolvedVersion = override?.version || autoVersion;
Comment on lines +175 to +178
const globalCommits = commits.filter((commit) => {
const files = commitFilesMap.get(commit.shortHash);
return files ? isGlobalCommit(workspaceRoot, files, packagePaths) : false;
});
Comment on lines +143 to 146
export function findCommitRange(packageCommits: Map<string, GitCommit[]>): { oldest: string; newest: string } | null {
let oldestCommit: string | null = null;
let newestCommit: string | null = null;

Comment on lines +13 to +17
function parseCLIFlags(): { dry: boolean; verbose: boolean; force: boolean } {
const { values } = parseArgs({
args: process.argv.slice(2),
options: {
dry: { type: "boolean", short: "d", default: false },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants