Skip to content

[mirror] Fix @fedify/nuxt runtime packaging and fedify init scaffolding edge cases#5

Open
yashwant86 wants to merge 14 commits intomm-base-717from
mm-pr-717
Open

[mirror] Fix @fedify/nuxt runtime packaging and fedify init scaffolding edge cases#5
yashwant86 wants to merge 14 commits intomm-base-717from
mm-pr-717

Conversation

@yashwant86
Copy link
Copy Markdown

@yashwant86 yashwant86 commented Apr 26, 2026

Mirror of upstream fedify-dev#717 for benchmark. Do not merge.


Summary by MergeMonkey

  • Knowledge Base:
    • Added `--allow-non-empty` CLI option documentation for `fedify init` command.
  • Enhancements:
    • Added `--allow-non-empty` flag to initialize projects in non-empty directories when framework scaffolder supports it.
    • Enhanced directory emptiness check to recognize unborn Git repositories as safe initialization targets.
    • Added runtime file path resolution for Nuxt module to use compiled JavaScript instead of TypeScript sources.
  • Squashed Bugs:
    • Fixed @fedify/nuxt runtime packaging to include compiled dist files instead of source TypeScript.
    • Fixed Redis message queue graceful shutdown to handle already-closed connections without throwing.
    • Fixed PostgreSQL message queue listen cleanup to properly unlisten and clear timeouts on abort.
    • Fixed Nuxt module to resolve runtime server files to compiled output paths.
  • Maintenance:
    • Updated Nuxt package.json to use catalog versions and add pretest build step.
    • Updated tsdown config to build runtime server files.
    • Removed @nuxt/schema from devDependencies (moved to peerDependencies).
    • Updated deno.lock to remove incorrect packageJson dependencies.

dahlia added 14 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
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
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
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
Move `@nuxt/schema` to peerDependencies in `@fedify/nuxt` and align the
lockfiles so tsdown no longer inlines the full Nuxt schema types into
`mod.d.(c)ts`.

References fedify-dev#717 (comment)

Assisted-by: Codex:gpt-5.4
Explain that `--allow-non-empty` only bypasses Fedify's own directory check,
that some framework scaffolders still reject unrelated files, and that the
generated-file conflict preflight only covers files written by Fedify itself.

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

Assisted-by: Codex:gpt-5.4
Move Nuxt peers onto the pnpm catalog and keep `pretest` scoped to
`build:self` so package-local tests only rebuild `@fedify/nuxt` itself.

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

Assisted-by: Codex:gpt-5.4
Cache the generated JSON config payloads per init run so the conflict
preflight and patching steps reuse the same loaded data instead of
re-reading configuration files.

References fedify-dev#717 (comment)

Assisted-by: Codex:gpt-5.4
Wait for PostgreSQL LISTEN cleanup before returning from queue shutdown,
and add an async Redis disposal path so Deno leak checks do not trip over
I/O timers left behind by ioredis disconnect.

Assisted-by: Codex:gpt-5.4
Use a stable cache key for generated JSON configs so the cache
survives `set()`-created data clones between the non-empty preflight
and the patch pipeline. Add a regression test that verifies the cache
key stays unchanged across those pipeline clones.

fedify-dev#717 (comment)

Assisted-by: Codex:gpt-5.4
@bot-mergemonkey
Copy link
Copy Markdown

bot-mergemonkey Bot commented Apr 26, 2026

Risk AssessmentNEEDS-TESTING · ~45 min review

Focus areas: Directory emptiness check with Git repository detection · Generated file conflict detection for --allow-non-empty · Nuxt runtime file path resolution and build output · Redis and PostgreSQL message queue cleanup logic

Assessment: Adds new CLI flag, changes directory validation logic, and fixes runtime file resolution.

Walkthrough

User runs fedify init --allow-non-empty in a directory with an unborn Git repository. The system checks if the directory is safe (empty or only .git), verifies no generated files already exist, then scaffolds the project. For Nuxt, the module now resolves runtime files to compiled dist output instead of source TypeScript, ensuring proper packaging.

Changes

Files Summary
Redis Message Queue Graceful Shutdown
packages/redis/src/mq.ts, mq.test.ts, mq.race.test.ts
Implements graceful Redis connection shutdown with asyncDispose support. Adds error handling for already-closed connections and unified test cleanup helper to properly await async disposal.
PostgreSQL Message Queue Listen Cleanup
packages/postgres/src/mq.ts
Fixes listen cleanup logic to properly unlisten and clear timeouts on abort signal. Adds connection destroyed error detection and ensures cleanup runs in finally block.
Fedify Init Allow Non-Empty Directory
packages/init/src/action/mod.ts
packages/init/src/action/patch.ts
packages/init/src/action/patch.test.ts
packages/init/src/ask/dir.ts
packages/init/src/command.ts
packages/init/src/lib.ts
packages/init/src/lib.test.ts
Adds `--allow-non-empty` flag to allow initialization in non-empty directories. Implements conflict detection for generated files and enhanced directory emptiness check that recognizes unborn Git repositories as safe targets.
Init Config and Package Tests
packages/init/src/action/configs.test.ts
packages/init/src/package.test.ts
Adds comprehensive tests for Biome config schema matching and npm initialization flow. Updates test data to include allowNonEmpty field.
Nuxt Runtime File Resolution
packages/nuxt/src/module.ts
packages/nuxt/src/module.test.ts
packages/nuxt/src/package.test.ts
packages/nuxt/package.json
packages/nuxt/tsdown.config.ts
Fixes Nuxt module to resolve runtime server files to compiled dist output instead of source TypeScript. Adds resolveRuntimeServerPath function and updates build config to compile runtime files. Removes src/runtime from package files list.
Fedify Test Message Queue Disposal
packages/fedify/src/federation/mq.test.ts
Adds unified disposeMessageQueue helper function to properly handle both sync and async disposal in tests, replacing inline disposal logic.
Documentation and Configuration
CHANGES.md
docs/cli.md
deno.lock
Documents new `--allow-non-empty` option and updates lock file dependencies.

Sequence Diagram

sequenceDiagram
  participant User
  participant CLI as fedify init
  participant DirCheck as isDirectoryEmpty
  participant GitCheck as isUnbornGitRepository
  participant ConflictCheck as assertNoGeneratedFileConflicts
  participant Scaffold as patchFiles
  User->>CLI: run with --allow-non-empty
  CLI->>DirCheck: check if dir is safe
  DirCheck->>GitCheck: verify .git is unborn
  GitCheck-->>DirCheck: true/false
  DirCheck-->>CLI: safe to proceed
  CLI->>ConflictCheck: verify no conflicts
  ConflictCheck-->>CLI: conflicts found or clear
  alt conflicts exist
    CLI-->>User: error: remove files or choose directory
  else no conflicts
    CLI->>Scaffold: create project files
    Scaffold-->>CLI: done
    CLI-->>User: success
  end
Loading

Dig Deeper With Commands

  • /review <file-path> <function-optional>
  • /chat <file-path> "<question>"
  • /roast <file-path>

Runs only when explicitly triggered.

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