-
-
Notifications
You must be signed in to change notification settings - Fork 91
Port Fedify CLI to run natively on Node.js and Bun #457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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]>
There was a problem hiding this 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
|
The docs for this pull request have been published: |
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.
|
The latest push to this pull request has been published to JSR and npm as a pre-release:
|
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
kv.bun.ts,kv.node.ts) for runtime-specific APIsTesting
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.