Skip to content

Fix @fedify/nuxt runtime packaging and fedify init scaffolding edge cases#717

Open
dahlia wants to merge 8 commits intofedify-dev:mainfrom
dahlia:bugfix/nuxt
Open

Fix @fedify/nuxt runtime packaging and fedify init scaffolding edge cases#717
dahlia wants to merge 8 commits intofedify-dev:mainfrom
dahlia:bugfix/nuxt

Conversation

@dahlia
Copy link
Copy Markdown
Member

@dahlia dahlia commented Apr 23, 2026

Summary

Closes #716.

This PR fixes the @fedify/nuxt packaging issue reported in #716 and also addresses the related fedify init side findings from the same issue.

For @fedify/nuxt, the Nuxt module now points Nitro at compiled runtime JavaScript in dist/ instead of package TypeScript sources. The runtime server entry points are included in the tsdown build, and the package-level regression test imports @fedify/nuxt from the built package output so this class of packaging issue is covered.

For @fedify/init, generated Biome configuration now matches the Biome 2 version that fedify init installs. The generated biome.json uses the Biome 2 assist.actions.source.organizeImports configuration, and the scaffold-level test checks that the schema version exactly matches the installed @biomejs/biome package version.

This also improves non-empty directory handling in fedify init. A directory that only contains a freshly initialized, unborn Git repository is now treated as empty, while repositories whose HEAD resolves to a commit or whose Git metadata contains refs are still treated as non-empty. Finally, a new --allow-non-empty option allows non-interactive scaffolding in directories with unrelated files, but fails before making changes if any file that Fedify would generate already exists.

Changes

  • Bundle Nuxt runtime server files with tsdown.
  • Resolve Nuxt middleware and server plugin paths from built dist/ files.
  • Add a package-level @fedify/nuxt import regression test against built output.
  • Update generated biome.json to Biome 2 syntax and schema version.
  • Add a scaffold-level Biome regression test that checks exact package/schema version matching.
  • Treat only unborn .git-only repositories as empty for fedify init.
  • Add --allow-non-empty for safe non-interactive init in non-empty directories.
  • Document --allow-non-empty in docs/cli.md.
  • Update CHANGES.md for the @fedify/init user-facing changes.

Verification

  • pnpm --dir packages/init --config.enable-pre-post-scripts=false test
  • deno task check in packages/init
  • hongdown --check CHANGES.md docs/cli.md
  • git diff --check
  • Commit hooks passed full repository checks, including formatting, linting, type checking, Markdown checking, version checks, and workspace protocol checks.

dahlia added 5 commits April 23, 2026 19:42
Build the Nuxt server runtime files as tsdown entry points and point
the Nuxt module at the generated JavaScript under dist.  This keeps
installed consumers from feeding TypeScript runtime sources into
Nitro's Rollup pipeline.

Add a package-level self-import test so the Node test path exercises
@fedify/nuxt through the package exports and catches missing built
runtime files before publishing.

Fixes fedify-dev#716

Assisted-by: Codex:gpt-5.4
Generated projects now use the Biome 2 configuration shape for
import organization, matching the @biomejs/biome version installed by
fedify init.

Add a scaffold-level regression test that creates an npm project and
checks the generated Biome schema version against the exact installed
Biome package version.

fedify-dev#716

Assisted-by: Codex:gpt-5.4
Treat a target directory that only contains a freshly initialized Git
repository as empty, while still rejecting repositories whose HEAD
resolves to a commit or whose .git metadata shows existing refs.

Add regression coverage for unborn repositories, committed repositories,
packed refs, detached HEADs, .git files, and additional project files.

fedify-dev#716

Assisted-by: Codex:gpt-5.4
Allow fedify init to run in non-empty directories when explicitly
requested, but check the files Fedify would generate before running any
framework scaffolding command.

The command now fails before making changes if a generated file already
exists, so unrelated files can coexist without accidental merges or
appends. Document the option and add regression coverage for the
conflict checks.

fedify-dev#716

Assisted-by: Codex:gpt-5.4
@dahlia dahlia added this to the Fedify 2.2 milestone Apr 23, 2026
@dahlia dahlia requested a review from Copilot April 23, 2026 11:24
@dahlia dahlia self-assigned this Apr 23, 2026
@dahlia dahlia added type/bug Something isn't working type/enhancement Improvements to existing features component/cli CLI tools related integration/nuxt Nuxt integration (@fedify/nuxt) labels Apr 23, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 99cd3a45-84b0-4cba-ba33-da9418e0f271

📥 Commits

Reviewing files that changed from the base of the PR and between 53dc63c and 11970a0.

📒 Files selected for processing (3)
  • CHANGES.md
  • packages/init/src/lib.test.ts
  • packages/init/src/lib.ts

📝 Walkthrough

Walkthrough

Adds a new --allow-non-empty init option with a preflight check that errors if would-be-generated files already exist, refines empty-directory detection to treat unborn Git repos as empty, updates generated Biome config to Biome 2 layout, and switches Nuxt runtime imports to built distribution artifacts.

Changes

Cohort / File(s) Summary
Init: CLI & control flow
packages/init/src/command.ts, packages/init/src/action/mod.ts, packages/init/src/ask/dir.ts
Adds --allow-non-empty option; threads allowNonEmpty through fillDir to skip empty-dir confirmation; invokes conflict assertion during hydrated init runs.
Init: Generated-file preflight
packages/init/src/action/patch.ts, packages/init/src/action/patch.test.ts
New exported assertNoGeneratedFileConflicts() and GeneratedFileConflictError; preflight collects deduped generated paths and fails with a formatted conflict error; tests for conflict detection.
Init: Empty-dir detection & tests
packages/init/src/lib.ts, packages/init/src/lib.test.ts
isDirectoryEmpty() now treats directories with only an unborn Git repo as empty using Git-state heuristics and subprocess checks; extensive tests for various Git states.
Init: Biome config & tests
packages/init/src/json/biome.json, packages/init/src/action/configs.test.ts
Upgrade Biome schema to 2.x and move organizeImports into assist.actions.source.organizeImports; tests updated to assert new schema and key path.
Init: Misc tests & fixtures
packages/init/src/package.test.ts, packages/init/src/action/configs.test.ts
Test adjustments to include allowNonEmpty in fixtures and new tests for Biome/patch behavior.
Docs & Changelog
CHANGES.md, docs/cli.md
Document --allow-non-empty behavior, non-empty detection policy, and Biome 2 output changes.
Nuxt: runtime build/imports & packaging
packages/nuxt/src/module.ts, packages/nuxt/tsdown.config.ts, packages/nuxt/src/module.test.ts, packages/nuxt/src/package.test.ts, packages/nuxt/package.json
Switch runtime imports to ../dist/runtime/server/*, add RuntimeResolver/resolveRuntimeServerPath(), adjust tsdown entries, add tests validating built-runtime paths, and update package files and pretest build hook.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant CLI as "fedify init CLI"
    participant fillDir as "fillDir"
    participant assertConflicts as "assertNoGeneratedFileConflicts"
    participant FS as "FileSystem"
    participant Init as "Init Handler"

    User->>CLI: run with --allow-non-empty
    CLI->>fillDir: call with allowNonEmpty=true
    fillDir->>CLI: return selected dir (skip prompt)
    CLI->>assertConflicts: run preflight check
    assertConflicts->>FS: stat/access deduped generated paths
    alt conflicts found
        assertConflicts-->>CLI: throw GeneratedFileConflictError (list paths)
        CLI-->>User: surface error and abort
    else no conflicts
        assertConflicts->>Init: proceed
        Init->>FS: write generated files (e.g., biome.json, package.json)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • 2chanhaeng
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.88% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main changes: fixes to @fedify/nuxt runtime packaging and fedify init scaffolding edge cases, matching the primary objectives of the changeset.
Description check ✅ Passed The description comprehensively relates to the changeset, covering all major modifications including Nuxt runtime packaging, Biome 2 configuration, directory emptiness checks, and the new --allow-non-empty option with supporting tests and documentation updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented Apr 23, 2026

@codex review

Copy link
Copy Markdown
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 pull request introduces the --allow-non-empty option to fedify init, allowing project initialization in non-empty directories while preventing overwrites of existing files. It also refines directory checks to treat freshly initialized Git repositories as empty and updates the generated Biome configuration to version 2 syntax. Furthermore, the Nuxt integration is updated to resolve runtime modules from the compiled dist directory. Feedback was provided to optimize file conflict detection by parallelizing asynchronous checks and simplifying path handling.

Comment thread packages/init/src/action/patch.ts
Copy link
Copy Markdown
Contributor

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 fixes a packaging regression in @fedify/nuxt that caused Nitro to bundle TypeScript runtime sources from node_modules, and it improves fedify init scaffolding to better handle non-empty directories, align generated Biome config with Biome 2, and support non-interactive workflows (closes #716).

Changes:

  • Bundle Nuxt runtime server entrypoints into dist/runtime/server/* and resolve Nitro middleware/plugin paths from built output.
  • Update fedify init to (a) treat “.git-only unborn repos” as empty, and (b) add --allow-non-empty with preflight conflict detection.
  • Update generated biome.json to Biome 2 syntax and add regression tests ensuring schema/package version alignment.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/nuxt/tsdown.config.ts Adds runtime server files as build entrypoints so compiled JS lands under dist/runtime/server/.
packages/nuxt/src/package.test.ts Adds a regression test ensuring module registration references dist/runtime/... and not src/runtime.
packages/nuxt/src/module.ts Resolves middleware/plugin paths via ../dist/runtime/server/*.js for Nitro integration.
packages/nuxt/src/module.test.ts Adds coverage for resolveRuntimeServerPath() to ensure compiled-runtime resolution behavior.
packages/nuxt/package.json Stops shipping src/runtime/ and ensures tests run against built output via pretest.
packages/init/src/package.test.ts Updates init package test data to include the new allowNonEmpty flag.
packages/init/src/lib.ts Enhances emptiness detection to treat only unborn .git-only repos as “empty”.
packages/init/src/lib.test.ts Adds tests for the unborn Git repo detection behavior.
packages/init/src/json/biome.json Updates the scaffolded Biome config to Biome 2 schema and assist.actions.source.organizeImports.
packages/init/src/command.ts Adds --allow-non-empty to the fedify init CLI options.
packages/init/src/ask/dir.ts Skips the non-empty directory prompt when --allow-non-empty is set.
packages/init/src/action/patch.ts Adds preflight detection to fail if any would-be generated files already exist when --allow-non-empty is used.
packages/init/src/action/patch.test.ts Adds tests for the generated-file conflict preflight behavior.
packages/init/src/action/mod.ts Wires the conflict preflight into the hydrated (non-dry-run) init flow.
packages/init/src/action/configs.test.ts Adds a regression test that schema version in biome.json matches the installed @biomejs/biome version.
docs/cli.md Documents the new --allow-non-empty option and its behavior.
CHANGES.md Adds changelog entries for the init behavior changes and links #716/#717.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fee5abcfbe

ℹ️ 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".

Comment thread packages/init/src/lib.ts Outdated
Parallelize generated-file conflict checks while preserving path
splitting for Windows-compatible path joins.

Treat any existing Git ref as evidence that a .git-only directory is not
fresh, including refs outside the current HEAD branch and any packed ref.

References fedify-dev#717 (comment)
References fedify-dev#717 (comment)

Assisted-by: Codex:gpt-5.4
@dahlia dahlia requested a review from Copilot April 23, 2026 11:34
@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented Apr 23, 2026

@codex review

@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented Apr 23, 2026

/gemini review

@issues-auto-labeler issues-auto-labeler Bot added component/build Build system and packaging component/integration Web framework integration labels Apr 23, 2026
Copy link
Copy Markdown
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 pull request introduces the --allow-non-empty option to fedify init, enabling project initialization in non-empty directories while ensuring existing files that would be generated are not overwritten. It also updates the isDirectoryEmpty logic to recognize unborn Git repositories as empty and migrates the generated Biome configuration to version 2 syntax. Furthermore, the Nuxt integration is updated to resolve runtime server files from the distribution directory. Feedback was provided to ensure npm package names in the documentation follow the project's convention of using italics instead of backticks.

Comment thread CHANGES.md
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ 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".

@dahlia dahlia marked this pull request as ready for review April 23, 2026 11:43
@dahlia dahlia requested a review from 2chanhaeng April 23, 2026 11:43
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 80.26316% with 45 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/init/src/lib.ts 73.07% 31 Missing and 11 partials ⚠️
packages/init/src/ask/dir.ts 0.00% 2 Missing ⚠️
packages/init/src/action/patch.ts 97.95% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
packages/init/src/action/mod.ts 100.00% <100.00%> (ø)
packages/init/src/command.ts 100.00% <100.00%> (ø)
packages/nuxt/src/module.ts 92.92% <100.00%> (+45.67%) ⬆️
packages/init/src/action/patch.ts 91.55% <97.95%> (+25.52%) ⬆️
packages/init/src/ask/dir.ts 21.62% <0.00%> (-0.30%) ⬇️
packages/init/src/lib.ts 67.75% <73.07%> (+13.72%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
CHANGES.md (1)

136-147: ⚠️ Potential issue | 🟡 Minor

Add the missing @fedify/nuxt packaging fix entry.

This PR also fixes the published Nuxt package/runtime entrypoint contract, but the unreleased changelog only documents the @fedify/init side. Please add a user-facing @fedify/nuxt entry and keep the first-use link definitions with that section.

📝 Proposed changelog addition
 ### `@fedify/nuxt`
 
  -  Added `@fedify/nuxt` package for integrating Fedify with [Nuxt].
     It provides a Nuxt module that delegates non-federation requests to Nuxt,
     supports shared-route content negotiation, and returns deferred
     `406 Not Acceptable` when Fedify routes are requested without
     ActivityPub-compatible `Accept` headers and Nuxt has no matching page.
     [[`#149`], [`#674`] by ChanHaeng Lee]
 
+ -  Fixed the published `@fedify/nuxt` package so its Nuxt module and Nitro
+    runtime middleware load compiled *dist/* JavaScript instead of TypeScript
+    source files.  This restores imports from the built package output in
+    Node.js package consumers.  [[`#716`], [`#717`]]
+
 [Nuxt]: https://nuxt.com/
 [`#149`]: https://github.com/fedify-dev/fedify/issues/149
 [`#674`]: https://github.com/fedify-dev/fedify/pull/674
+[`#716`]: https://github.com/fedify-dev/fedify/issues/716
+[`#717`]: https://github.com/fedify-dev/fedify/pull/717
@@
-[`#716`]: https://github.com/fedify-dev/fedify/issues/716
-[`#717`]: https://github.com/fedify-dev/fedify/pull/717

As per coding guidelines, “Update CHANGES.md with the issue number, PR number, and your name when fixing bugs.”

Also applies to: 182-183

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGES.md` around lines 136 - 147, Update CHANGES.md to add a user-facing
packaging fix entry under the `@fedify/nuxt` section describing the Nuxt
package/runtime entrypoint contract fix (include the related issue number, PR
number, and your name as per guidelines), and ensure the first-use link
definitions for [Nuxt], [`#149`], and [`#674`] are present with that section; also
apply the same packaging-fix entry to the corresponding nearby lines referenced
(the other occurrence around lines 182-183) so both places document the fix
consistently.
packages/init/src/action/patch.ts (1)

47-154: 🧹 Nitpick | 🔵 Trivial

Pre-flight conflict detection looks correct; minor nit on path splitting.

Logic and error reporting are solid: gated on allowNonEmpty, de-duped via Set, parallelized with Promise.all, and ENOENT correctly classified via throwUnlessNotExists.

Nit (non-blocking): path.split("/") at Line 131 assumes generated paths always use forward slashes. Today that holds because initializer file keys and .env/framework files use /, but some devToolConfigs entries are built via joinPath(".vscode", "extensions.json"), which is OS-dependent. On the current Unix-only dev/test environment this is fine, but a future Windows-capable run would silently produce a single un-split segment. Consider using joinPath(data.dir, path) directly (Node's path.join already normalizes forward slashes on POSIX and handles either separator on Windows), e.g.:

Suggested simplification
-      const exists = await pathExists(joinPath(data.dir, ...path.split("/")));
+      const exists = await pathExists(joinPath(data.dir, path));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/init/src/action/patch.ts` around lines 47 - 154, The path-splitting
in getExistingGeneratedFiles uses path.split("/") which assumes forward slashes;
change the existence check to call joinPath(data.dir, path) directly (instead of
joinPath(data.dir, ...path.split("/"))) so OS-native separators from entries
produced by joinPath (e.g., devToolConfigs) are handled correctly; update the
map in getExistingGeneratedFiles to use joinPath(data.dir, path) and keep the
rest of the logic (paths, Promise.all, pathExists) intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGES.md`:
- Around line 157-160: Update the CHANGES.md entry for "Fixed `fedify init`" to
explicitly mention that Git refs/packed-refs are treated as non-empty: clarify
that directories where .git contains refs (including packed-refs) are considered
non-empty even if HEAD is unborn, and only a directory with a freshly
initialized Git repo with no refs and no files outside *.git* is treated as
empty; keep the user-facing tone (what changed, why, and what users should do)
and reference the `fedify init` behavior and Git refs/packed-refs in the
description.

In `@packages/init/src/lib.ts`:
- Around line 257-262: The parseHeadRef function currently parses and returns a
ref string but callers (looksLikeUnbornGitRepository) only test for null, so the
actual branch name is unused; either make parseHeadRef a boolean predicate
(e.g., isHeadRefValid) and update callers to use the boolean, or keep
parseHeadRef returning the ref and modify looksLikeUnbornGitRepository to use
the returned ref to directly check the exact branch file (refs/heads/<branch>)
before falling back to loose-ref scanning; update calls and tests accordingly
and keep the unique symbols parseHeadRef and looksLikeUnbornGitRepository in
mind when making the change.

---

Outside diff comments:
In `@CHANGES.md`:
- Around line 136-147: Update CHANGES.md to add a user-facing packaging fix
entry under the `@fedify/nuxt` section describing the Nuxt package/runtime
entrypoint contract fix (include the related issue number, PR number, and your
name as per guidelines), and ensure the first-use link definitions for [Nuxt],
[`#149`], and [`#674`] are present with that section; also apply the same
packaging-fix entry to the corresponding nearby lines referenced (the other
occurrence around lines 182-183) so both places document the fix consistently.

In `@packages/init/src/action/patch.ts`:
- Around line 47-154: The path-splitting in getExistingGeneratedFiles uses
path.split("/") which assumes forward slashes; change the existence check to
call joinPath(data.dir, path) directly (instead of joinPath(data.dir,
...path.split("/"))) so OS-native separators from entries produced by joinPath
(e.g., devToolConfigs) are handled correctly; update the map in
getExistingGeneratedFiles to use joinPath(data.dir, path) and keep the rest of
the logic (paths, Promise.all, pathExists) intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: fb2572f6-a229-45f5-8e26-6b042a93819c

📥 Commits

Reviewing files that changed from the base of the PR and between 44ea8f2 and dc16653.

📒 Files selected for processing (17)
  • CHANGES.md
  • docs/cli.md
  • packages/init/src/action/configs.test.ts
  • packages/init/src/action/mod.ts
  • packages/init/src/action/patch.test.ts
  • packages/init/src/action/patch.ts
  • packages/init/src/ask/dir.ts
  • packages/init/src/command.ts
  • packages/init/src/json/biome.json
  • packages/init/src/lib.test.ts
  • packages/init/src/lib.ts
  • packages/init/src/package.test.ts
  • packages/nuxt/package.json
  • packages/nuxt/src/module.test.ts
  • packages/nuxt/src/module.ts
  • packages/nuxt/src/package.test.ts
  • packages/nuxt/tsdown.config.ts

Comment thread CHANGES.md Outdated
Comment thread packages/init/src/lib.ts Outdated
Clarify the changelog wording for Git refs in freshly initialized
repositories, simplify HEAD ref validation to a boolean predicate, and use
path.join() directly when checking generated-file conflicts.

References fedify-dev#717 (comment)
References fedify-dev#717 (comment)
References fedify-dev#717 (comment)

Assisted-by: Codex:gpt-5.4
@dahlia
Copy link
Copy Markdown
Member Author

dahlia commented Apr 23, 2026

Regarding the CodeRabbit outside-diff suggestions in #717 (comment): I did not add an @fedify/nuxt changelog entry because @fedify/nuxt has not had a formal release yet. The path-joining nit was fixed in 53dc63c by using joinPath(data.dir, path).

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/init/src/lib.ts`:
- Around line 240-253: The function looksLikeUnbornGitRepository currently only
checks refs and HEAD but must also reject repositories with existing object DB
or state files; modify looksLikeUnbornGitRepository to return false if the
.git/objects directory contains any loose objects or packfiles, if an index file
exists (check joinPath(gitDir, "index") via isFile or equivalent), or if
reflogs/logs are present (check joinPath(gitDir, "logs") and ensure it’s empty).
Implement small helpers (e.g., hasAnyLooseObjects, hasAnyPackfiles,
hasAnyFilesInDir) or reuse/extend hasAnyLooseRef/hasAnyPackedRef to perform
these checks and call them before returning true. Ensure you reference gitDir
and use existing helpers like isDirectory/isFile/readGitFile where appropriate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 01b886c3-cd07-4e3c-855f-bb7d9e2d8bff

📥 Commits

Reviewing files that changed from the base of the PR and between dc16653 and 53dc63c.

📒 Files selected for processing (3)
  • CHANGES.md
  • packages/init/src/action/patch.ts
  • packages/init/src/lib.ts

Comment thread packages/init/src/lib.ts
Treat an unborn Git repository as empty only when it has no refs, stored
objects, index, reflogs, or other common state paths.  This keeps fedify init
from skipping the non-empty-directory safeguard for repositories with deleted
refs but remaining Git state.

References fedify-dev#717 (comment)

Assisted-by: Codex:gpt-5.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/build Build system and packaging component/cli CLI tools related component/integration Web framework integration integration/nuxt Nuxt integration (@fedify/nuxt) type/bug Something isn't working type/enhancement Improvements to existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@fedify/nuxt: Nitro fails to bundle runtime because dist/mod.js references the TypeScript sources directly

2 participants