Fix fedify init crash on JSR/Deno distribution#633
Fix fedify init crash on JSR/Deno distribution#633dahlia merged 1 commit intofedify-dev:2.0-maintenancefrom
fedify init crash on JSR/Deno distribution#633Conversation
Summary of ChangesHello, 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 resolves a critical issue where the 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. Footnotes
|
|
@codex review |
There was a problem hiding this comment.
Code Review
This pull request effectively fixes a crash in fedify init when run from a JSR/Deno distribution by making template loading compatible with remote module execution. The changes are well-implemented, using lazy initialization for repository-relative paths and adding an async, fetch-based fallback for readTemplate. The related type and function signature updates across the init package are consistent and correct. I have one suggestion to improve documentation in line with the project's standards, as detailed in the comment.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a97f15ba5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
`@fedify/init` crashed when executed through the JSR/Deno distribution
(e.g., `deno run -A jsr:@fedify/cli init`) because `import.meta.dirname`
is `undefined` for remote JSR modules.
Two fixes applied:
- Made `PACKAGES_PATH` lazy by converting it to a `getPackagesPath()`
function. This constant was eagerly computed at module top-level
using `import.meta.dirname!`, causing an immediate crash on import.
Since it is only used in test mode (which always runs locally),
deferring the computation is safe.
- Made `readTemplate()` async with a URL-based fallback. When
`import.meta.dirname` is available (Node.js, local Deno, deno
compile), the existing `readFileSync` path is used. When it is
not (JSR remote execution), `import.meta.url` + `fetch()` is used
to load template files from the JSR CDN.
Fixes fedify-dev#624
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6a97f15 to
12093e7
Compare
|
Pre-release has been published for this pull request: Packages
|
|
Verified with the JSR pre-release. The original crash from #624 is fixed: $ deno run -A jsr:@fedify/cli@2.0.6-pr.633.9+12093e72 init --help
Initialize a new Fedify project directory.
Usage: fedify init [-w/--web-framework WEB_FRAMEWORK] [-p/--package-manager PACKAGE_MANAGER] [-k/--kv-store KV_STORE] [-m/--message-queue MESSAGE_QUEUE] [--dry-run] [[-d/--debug]] [(--ignore-config | --config PATH)] [DIR]
...No crash — help output is displayed as expected. |
Summary
fedify initcrashing when@fedify/clior@fedify/initis executed through the JSR/Deno distribution (e.g.,deno run -A jsr:@fedify/cli init).import.meta.dirnameisundefinedfor remote JSR modules, so the template loading and repository-relative path logic has been made safe for published JSR execution.Changes
PACKAGES_PATHlazy by converting it to agetPackagesPath()function. This constant was eagerly computed at module top-level usingimport.meta.dirname!, causing an immediate crash on import. Since it is only used in test mode (which always runs locally), deferring the computation is safe.readTemplate()async with a URL-based fallback. Whenimport.meta.dirnameis available (Node.js, local Deno,deno compile), the existingreadFileSyncpath is used. When it is not (JSR remote execution),import.meta.url+fetch()is used to load template files from the JSR CDN.Test plan
deno checkpasses for all files in the init packagedeno task checkpasses (fmt, lint, type check) in the init packagedeno run -A packages/cli/src/mod.ts init --helpworks without crashingtsdownbuild succeeds and produces correct output (templates copied todist/,import.meta.dirnameguard present in built JS)fetch()path works withfile://URLs (for the JSR fallback path)Closes #624