Skip to content

Conversation

@dahlia
Copy link
Member

@dahlia dahlia commented Oct 8, 2025

Resolves #456 (part of #374)

Summary

This PR ports the Fedify CLI to run natively on Node.js and Bun, eliminating the need for compiled binaries distributed via npm. The CLI now runs as JavaScript source across all three major JavaScript runtimes (Deno, Node.js, and Bun).

Changes

  • Cross-runtime compatibility: Replaced Deno-specific standard library dependencies with universal alternatives
  • Image rendering: Ported CLI image renderer from Deno-specific APIs to Node.js/Bun-compatible implementation using jimp and universal dependencies
  • Test infrastructure: Migrated CLI tests from Deno test framework to Node.js test framework for cross-runtime testing
  • Build configuration: Added tsdown configuration and build process for Node.js/Bun distribution
  • Runtime abstractions: Added platform-specific modules (e.g., kv.bun.ts, kv.node.ts) for runtime-specific APIs

Testing

  • CLI tests now run on Node.js/Bun in addition to Deno
  • All existing functionality maintained across runtimes

This completes the cross-runtime transition for Fedify CLI as envisioned in the Fedify 2.0 roadmap, providing a more natural JavaScript package experience for Node.js and Bun users.

dahlia and others added 5 commits October 8, 2025 22:39
Add support for running Fedify CLI natively on Node.js and Bun by
replacing Deno-specific APIs with cross-runtime alternatives and
implementing runtime-specific KV store adapters using SQLite.

- Replace @cross/dir with env-paths for cache management
- Replace @std/encoding/base64 with byte-encodings
- Replace @std/path with node:path
- Add runtime-specific KV implementations (kv.node.ts, kv.bun.ts)
- Add tsdown build configuration
- Update package.json with bin entry and build scripts
- Add shebang to src/mod.ts

Node.js basic functionality confirmed. Bun support not yet tested.

fedify-dev#456
Replace Deno-specific APIs with Node.js equivalents:
- Use fs/promises for file operations instead of Deno.readFile/writeFile
- Use process.env and process.stderr instead of Deno.env and Deno.stderr
- Update temp file creation to use fs.mkdtemp with path.join
- Upgrade @optique/core and @optique/run to v0.6.1 (stable release)

Co-Authored-By: Claude <[email protected]>
Switch from Deno-specific @std modules to cross-runtime equivalents:

- Replace @std/fmt/colors with chalk for terminal colors
- Remove @std/dotenv dependency
- Remove @david/dax dependency

Update color handling in CLI tools to use chalk API instead of
@std/fmt/colors, providing consistent cross-runtime color support.
Replace Deno testing tools with Node.js equivalents:

- Replace @std/assert with node:assert/strict
- Use Node.js built-in test runner (node:test)
- Replace Deno.inspect with util.inspect
- Update getAsciiArt signature to accept ChalkInstance parameter
- Add test and test:bun scripts to package.json

Other improvements:

- Accept Temporal.DurationLike in KvCache rules for flexibility
- Exclude dist/ directory from Deno tasks
- Add test task to deno.json with codegen dependency
Ensure CLI is built before running tests in both Node.js and Bun
environments to avoid module resolution errors.
@issues-auto-labeler issues-auto-labeler bot added breaking change Breaking change component/cli CLI tools related difficulty/intermediate Intermediate level examples Example code related labels Oct 8, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dahlia, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request ports the Fedify CLI to run natively on Node.js and Bun, in addition to Deno. Key changes include replacing Deno-specific APIs with universal alternatives, refactoring the image renderer, abstracting the KV store with runtime-specific implementations, and migrating the build and test infrastructure to support Node.js and Bun. This enhances the CLI's portability and provides a more natural JavaScript package experience.

Highlights

  • Intent: The primary goal of this pull request is to enable the Fedify CLI to run natively on Node.js and Bun, in addition to Deno. This eliminates the need for pre-compiled binaries and provides a more standard JavaScript package experience across major runtimes, aligning with the Fedify 2.0 roadmap.
  • Key Changes: - Cross-Runtime Compatibility: Replaced Deno-specific standard library imports (e.g., @std/fs, @std/path, Deno.env.get, Deno.readFile, Deno.inspect) with universal Node.js built-in modules (node:fs/promises, node:path, node:os, node:process, node:util) and npm packages (env-paths, chalk, byte-encodings).
  • Image Rendering Porting: The CLI's image renderer was refactored to use jimp and Node.js-compatible APIs for image processing and terminal output, replacing Deno-specific file system and environment interactions.
  • KV Store Abstraction: Introduced runtime-specific KV store implementations (kv.bun.ts, kv.node.ts) using bun:sqlite and node:sqlite respectively, accessed via a new #kv import alias, replacing the Deno-specific DenoKvStore.
  • Build and Test Infrastructure: Added tsdown configuration (tsdown.config.ts) for building the CLI for Node.js. Updated package.json to include bin, exports, imports fields for Node.js/Bun distribution, along with new devDependencies and test scripts (test, test:bun). CLI tests were migrated from Deno's test framework to Node.js's native test runner (node:test) and assertion libraries (node:assert/strict).
  • API Enhancements: The KvCacheParameters.rules type in @fedify/fedify was broadened to accept Temporal.DurationLike in addition to Temporal.Duration, offering more flexibility.
  • Impact: This PR significantly enhances the portability and accessibility of the Fedify CLI, allowing it to run natively on Node.js and Bun without requiring Deno or pre-compiled binaries. This provides a more natural JavaScript package experience for Node.js and Bun users.
  • Testing: The changes are verified by migrating existing CLI tests to run on Node.js's native test framework and adding new test scripts for both Node.js and Bun environments. All existing CLI functionality is maintained across the supported runtimes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dahlia dahlia linked an issue Oct 8, 2025 that may be closed by this pull request
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is a significant and well-executed pull request that successfully ports the Fedify CLI to be cross-runtime compatible with Node.js and Bun. The changes are extensive, touching dependencies, build configurations, and replacing Deno-specific APIs with universal or platform-specific abstractions. The use of tsdown for the build process and the creation of runtime-specific modules like kv.bun.ts are excellent patterns for this kind of refactoring.

I've identified a couple of areas for improvement related to maintainability and correctness. My comments focus on a risky type assertion and an incorrect implementation of the NO_COLOR standard. Addressing these will enhance the robustness and clarity of the codebase.

Overall, great work on this complex porting effort!

Document the CLI's cross-runtime compatibility improvements that eliminate
the need for compiled binaries on Node.js and Bun platforms.

Co-Authored-By: Claude <[email protected]>
@dahlia dahlia requested a review from Copilot October 8, 2025 14:22
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 ports the Fedify CLI to run natively on Node.js and Bun, eliminating the need for compiled binaries distributed via npm. The CLI now runs as JavaScript source across all three major JavaScript runtimes (Deno, Node.js, and Bun).

  • Replaces Deno-specific standard library dependencies with universal alternatives
  • Migrates image rendering from Deno-specific APIs to Node.js/Bun-compatible implementation using jimp and universal dependencies
  • Transitions CLI tests from Deno test framework to Node.js test framework for cross-runtime testing

Reviewed Changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Adds Bun types and byte-encodings to catalog dependencies
packages/sqlite/src/kv.ts Removes unused Temporal polyfill import
packages/sqlite/src/kv.test.ts Updates import path to use package-relative imports
packages/fedify/src/utils/kv-cache.ts Enhances KvCacheParameters to accept Temporal.DurationLike in addition to Temporal.Duration
packages/cli/tsdown.config.ts Adds tsdown configuration for Node.js/Bun builds
packages/cli/src/mod.ts Adds Node.js shebang for executable CLI
packages/cli/src/utils.ts Migrates from Deno APIs to Node.js APIs for process and color handling
packages/cli/src/nodeinfo.ts Replaces Deno-specific color and environment APIs with Node.js equivalents
packages/cli/src/kv.node.ts Implements Node.js-specific KV store using Node.js SQLite
packages/cli/src/kv.bun.ts Implements Bun-specific KV store using Bun SQLite
packages/cli/src/docloader.ts Replaces DenoKvStore with runtime-specific KV store implementation
packages/cli/src/imagerenderer.ts Migrates image rendering from Deno APIs to Node.js file system APIs
packages/cli/src/cache.ts Replaces Deno directory utilities with env-paths for cross-platform cache directory
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2025

The docs for this pull request have been published:

https://b3c17178.fedify.pages.dev

dahlia and others added 2 commits October 9, 2025 13:15
Replace circular reference assertions with proper boolean checks.
The previous implementation used spread operators that created
circular references, making the tests always pass.

Co-Authored-By: Claude <[email protected]>
Remove the exclusion of CLI tarball from non-tag builds and add
npm package link for @fedify/cli in the PR comment, reflecting
that the CLI is now distributed as a JavaScript package on npm
instead of compiled binaries.
@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

The latest push to this pull request has been published to JSR and npm as a pre-release:

Package Version JSR npm
@fedify/fedify 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/cli 2.0.0-pr.457.1756+27d73176 JSR
@fedify/amqp 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/cfworkers 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/denokv 2.0.0-pr.457.1756+27d73176 JSR
@fedify/elysia 2.0.0-pr.457.1756+27d73176 npm
@fedify/express 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/h3 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/hono 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/koa 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/nestjs 2.0.0-pr.457.1756+27d73176 npm
@fedify/next 2.0.0-pr.457.1756+27d73176 npm
@fedify/postgres 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/redis 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/sqlite 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/sveltekit 2.0.0-pr.457.1756+27d73176 JSR npm
@fedify/testing 2.0.0-pr.457.1756+27d73176 JSR npm

@dahlia dahlia added this to the Fedify 2.0 milestone Oct 9, 2025
@dahlia dahlia merged commit 5037a70 into fedify-dev:next Oct 9, 2025
10 checks passed
@dahlia dahlia deleted the universal-runtime-cli branch October 9, 2025 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Breaking change component/cli CLI tools related difficulty/intermediate Intermediate level examples Example code related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port Fedify CLI to run natively on Node.js and Bun

1 participant