Skip to content

fix(nx): add Nx monorepo support with scaffolding instructions and commands#284

Merged
frontegg-david merged 3 commits intorelease/1.0.xfrom
fix-nx
Mar 17, 2026
Merged

fix(nx): add Nx monorepo support with scaffolding instructions and commands#284
frontegg-david merged 3 commits intorelease/1.0.xfrom
fix-nx

Conversation

@frontegg-david
Copy link
Contributor

@frontegg-david frontegg-david commented Mar 17, 2026

fixes: #281

Summary by CodeRabbit

  • Documentation

    • Installation and quickstart now use tabs for Standard and Nx monorepo flows; expanded commands, examples, project structure, and Next Steps guidance.
  • New Features

    • Nx monorepo workspace scaffolding and generator support, including bootstrapped tooling, multi-package-manager flows, and .nvmrc output.
  • Tests

    • Added tests for Nx scaffold behavior, README and .nvmrc generation, package-manager scenarios, and various success/failure paths.
  • Chores

    • ESLint and Nx config adjustments to exclude end-to-end test directories.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

Adds Nx monorepo scaffolding to the CLI (--nx), bootstraps local Nx tooling before generation, writes .nvmrc and README templates, updates docs with Nx workflows (installation/quickstart), extends tests for Nx flows, and adjusts ESLint / nx.json plugin exclude patterns.

Changes

Cohort / File(s) Summary
Documentation
docs/frontmcp/getting-started/installation.mdx, docs/frontmcp/getting-started/quickstart.mdx
Introduce tabbed UI with Standard and Nx Monorepo flows; add Nx-specific create/add flows, examples for npm/yarn/pnpm/nx, new commands and next-step guidance, and many new code blocks.
CLI scaffold implementation & tests
libs/cli/src/commands/scaffold/create.ts, libs/cli/src/commands/scaffold/__tests__/create.spec.ts
Add scaffoldNxWorkspace flow, getInstallCommand helper, bootstrap package.json + install step, dynamic local loading via createRequire, .nvmrc handling, more granular directory/emptiness checks, expanded error handling/messages, and extensive Nx-focused tests with mocking of installs and module resolution.
Nx plugin templates & generator tests
libs/nx-plugin/src/generators/workspace/files/README.md__tmpl__, libs/nx-plugin/src/generators/workspace/files/__dot__nvmrc__tmpl__, libs/nx-plugin/src/generators/workspace/workspace.spec.ts
Add README and .nvmrc templates (Node 24) for workspace generator and tests asserting README content and .nvmrc presence and content.
Configs
eslint.config.mjs, nx.json
Extend ESLint ignores to include apps/e2e/**; move/add eslint plugin exclude pattern to plugin-level in nx.json (apps/e2e/**/*).

Sequence Diagram(s)

sequenceDiagram
    participant CLI as FrontMCP CLI
    participant FS as File System
    participant PM as Package Manager
    participant NX as Local Nx (node_modules)
    participant Gen as Nx Workspace Generator

    CLI->>FS: write bootstrap package.json (nx devDeps)
    CLI->>PM: run install in target (bootstrap)
    PM->>FS: install nx into node_modules
    CLI->>NX: createRequire -> load local nx modules
    CLI->>Gen: invoke workspaceGenerator (skipInstall:true, createSampleApp:true)
    Gen->>FS: generate workspace files (README, .nvmrc, apps/libs)
    CLI->>PM: run install in generated workspace (full deps)
    PM->>FS: install project dependencies
    CLI->>FS: output next-steps and completion messages
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐇 I hopped in with a bootstrap pack,
wrote README, .nvmrc, and an Nx track.
Install, require, generate with cheer —
monorepos sprout and projects appear.
Happy hops — your workspace is near!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 65.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(nx): add Nx monorepo support with scaffolding instructions and commands' directly and clearly describes the main changes: fixing Nx monorepo support with new scaffolding features, which aligns with the substantial documentation and code changes across multiple files.
Linked Issues check ✅ Passed The PR successfully addresses issue #281 by implementing Nx workspace scaffolding that properly resolves and installs Nx dependencies before use, including bootstrap package.json creation, local require resolution, and comprehensive error handling.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing Nx monorepo support: documentation updates (installation/quickstart guides), scaffolding implementation (create.ts with Nx flow), tests (create.spec.ts), Nx generator templates (README, .nvmrc), and ESLint/Nx configuration updates for the feature.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-nx
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@frontegg-david frontegg-david changed the title fix(nx): add Nx monorepo support with scaffolding instructions and commands #281 fix(nx): add Nx monorepo support with scaffolding instructions and commands Mar 17, 2026
@frontegg-david frontegg-david self-assigned this Mar 17, 2026
Copy link
Contributor

@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

🧹 Nitpick comments (1)
libs/cli/src/commands/scaffold/__tests__/create.spec.ts (1)

762-770: Consider using @frontmcp/utils for test setup file operations.

Direct require('fs') usage at lines 764-765 bypasses the project convention of using @frontmcp/utils for file system operations. While acceptable in test setup code, consider using the utility for consistency.

♻️ Optional refactor to use `@frontmcp/utils`
-    require('fs').mkdirSync(projectDir);
-    require('fs').writeFileSync(path.join(projectDir, 'file.txt'), 'content');
+    const { mkdirSync, writeFileSync } = require('fs');
+    mkdirSync(projectDir);
+    writeFileSync(path.join(projectDir, 'file.txt'), 'content');

Or alternatively, add mkdirSync and writeFileSync to the imports at line 2 to maintain consistency with the existing direct fs usage pattern in this test file.

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

In `@libs/cli/src/commands/scaffold/__tests__/create.spec.ts` around lines 762 -
770, The test uses direct require('fs') calls to create files in the "should
refuse to scaffold into non-empty directory" test; replace those direct requires
with the project's file-utils by importing and using the equivalent helpers from
`@frontmcp/utils` (or add mkdirSync and writeFileSync to the existing imports) so
the setup uses the same utility abstractions as other tests—adjust the lines
that call require('fs').mkdirSync and require('fs').writeFileSync to call the
`@frontmcp/utils` helpers instead while keeping the rest of the test (runCreate
and the consoleLogs assertion) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@libs/cli/src/commands/scaffold/create.ts`:
- Around line 1182-1205: Replace direct usage of fsp.stat with the project's fs
utility: import and use the stat function from `@frontmcp/utils` instead of
calling fsp.stat(projectDir). In the validation block that references projectDir
(and later calls isDirEmpty and ensureDir), call stat(projectDir) from the utils
package and keep the surrounding logic unchanged so ENOENT handling and
subsequent ensureDir(projectDir) still work.

---

Nitpick comments:
In `@libs/cli/src/commands/scaffold/__tests__/create.spec.ts`:
- Around line 762-770: The test uses direct require('fs') calls to create files
in the "should refuse to scaffold into non-empty directory" test; replace those
direct requires with the project's file-utils by importing and using the
equivalent helpers from `@frontmcp/utils` (or add mkdirSync and writeFileSync to
the existing imports) so the setup uses the same utility abstractions as other
tests—adjust the lines that call require('fs').mkdirSync and
require('fs').writeFileSync to call the `@frontmcp/utils` helpers instead while
keeping the rest of the test (runCreate and the consoleLogs assertion)
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5b35a195-6144-45d4-9bc9-8de9e1fb05a9

📥 Commits

Reviewing files that changed from the base of the PR and between dd53e25 and c084b15.

📒 Files selected for processing (9)
  • docs/frontmcp/getting-started/installation.mdx
  • docs/frontmcp/getting-started/quickstart.mdx
  • eslint.config.mjs
  • libs/cli/src/commands/scaffold/__tests__/create.spec.ts
  • libs/cli/src/commands/scaffold/create.ts
  • libs/nx-plugin/src/generators/workspace/files/README.md__tmpl__
  • libs/nx-plugin/src/generators/workspace/files/__dot__nvmrc__tmpl__
  • libs/nx-plugin/src/generators/workspace/workspace.spec.ts
  • nx.json

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

Performance Test Results

Status: ✅ All tests passed

Summary

Project Tests Passed Warnings Failed Leaks
✅ demo-e2e-agents 4 4 0 0 0
✅ demo-e2e-cache 11 11 0 0 0
✅ demo-e2e-codecall 4 4 0 0 0
✅ demo-e2e-config 4 4 0 0 0
✅ demo-e2e-direct 3 3 0 0 0
✅ demo-e2e-elicitation 1 1 0 0 0
✅ demo-e2e-errors 4 4 0 0 0
✅ demo-e2e-hooks 3 3 0 0 0
✅ demo-e2e-multiapp 4 4 0 0 0
✅ demo-e2e-notifications 3 3 0 0 0
✅ demo-e2e-openapi 2 2 0 0 0
✅ demo-e2e-providers 4 4 0 0 0
✅ demo-e2e-public 4 4 0 0 0
✅ demo-e2e-redis 14 14 0 0 0
✅ demo-e2e-remember 4 4 0 0 0
✅ demo-e2e-remote 5 5 0 0 0
✅ demo-e2e-serverless 2 2 0 0 0
✅ demo-e2e-skills 15 15 0 0 0
✅ demo-e2e-standalone 2 2 0 0 0
✅ demo-e2e-transport-recreation 3 3 0 0 0
✅ demo-e2e-ui 4 4 0 0 0

Total: 100 tests across 21 projects

📊 View full report in workflow run


Generated at: 2026-03-17T09:45:45.170Z
Commit: 1e4e3c12

Copy link
Contributor

@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 `@libs/cli/src/commands/scaffold/__tests__/create.spec.ts`:
- Line 2: Replace the direct Node fs imports (mkdtempSync, mkdirSync, rmSync,
readFileSync, writeFileSync, existsSync) with the corresponding exports from
`@frontmcp/utils` (mkdtemp, mkdir, rm, readFile, writeFile, fileExists); update
the import statement accordingly and refactor test usages to the async variants
where sync counterparts are not provided (await
mkdtemp/mkdir/rm/readFile/writeFile and use await fileExists) and adjust any
assertions or setup/teardown to handle Promises; target usages include the
functions named mkdtempSync, mkdirSync, rmSync, readFileSync, writeFileSync,
existsSync in create.spec.ts and replace them with mkdtemp, mkdir, rm, readFile,
writeFile, fileExists respectively.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9d2a6e5d-c12c-4301-bf6c-b2ea43f52827

📥 Commits

Reviewing files that changed from the base of the PR and between c084b15 and 3d65393.

📒 Files selected for processing (2)
  • libs/cli/src/commands/scaffold/__tests__/create.spec.ts
  • libs/cli/src/commands/scaffold/create.ts

Copy link
Contributor

@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.

Caution

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

⚠️ Outside diff range comments (1)
libs/cli/src/commands/scaffold/__tests__/create.spec.ts (1)

548-563: ⚠️ Potential issue | 🟡 Minor

Resource leak: temp directory is not cleaned up.

The tempDir variable is declared locally inside beforeEach, making it inaccessible in afterEach. This causes temp directories to accumulate without cleanup.

🧹 Proposed fix to ensure cleanup
 describe('sanitizeForFolder', () => {
+  let tempDir: string;
+
   beforeEach(async () => {
-    const tempDir = await mkdtemp(path.join(tmpdir(), 'cli-test-'));
+    tempDir = await mkdtemp(path.join(tmpdir(), 'cli-test-'));
     jest.spyOn(process, 'cwd').mockReturnValue(tempDir);
     jest.spyOn(process, 'chdir').mockImplementation(() => {
       // No-op for testing
     });
     jest.spyOn(process, 'exit').mockImplementation(((code?: number) => {
       throw new Error(`process.exit(${code})`);
     }) as () => never);
     Object.defineProperty(process.stdin, 'isTTY', { value: false, writable: true, configurable: true });
   });

-  afterEach(() => {
+  afterEach(async () => {
     jest.restoreAllMocks();
+    try {
+      await rm(tempDir, { recursive: true, force: true });
+    } catch {
+      // Ignore cleanup errors
+    }
   });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/cli/src/commands/scaffold/__tests__/create.spec.ts` around lines 548 -
563, The test leaks temp dirs because tempDir is declared inside beforeEach;
move tempDir to an outer-scoped variable (e.g., let tempDir: string) so
afterEach can access it, create it in beforeEach via mkdtemp, and remove it in
afterEach using fs.rm or fs.rmSync (with recursive/force) or fs.promises.rm to
delete the directory; keep existing jest.restoreAllMocks but ensure you guard
removal if tempDir is undefined or already removed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@libs/cli/src/commands/scaffold/__tests__/create.spec.ts`:
- Around line 548-563: The test leaks temp dirs because tempDir is declared
inside beforeEach; move tempDir to an outer-scoped variable (e.g., let tempDir:
string) so afterEach can access it, create it in beforeEach via mkdtemp, and
remove it in afterEach using fs.rm or fs.rmSync (with recursive/force) or
fs.promises.rm to delete the directory; keep existing jest.restoreAllMocks but
ensure you guard removal if tempDir is undefined or already removed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fdd57186-5b01-4aab-ab77-9455b529f05a

📥 Commits

Reviewing files that changed from the base of the PR and between 3d65393 and 7569241.

📒 Files selected for processing (1)
  • libs/cli/src/commands/scaffold/__tests__/create.spec.ts

@frontegg-david frontegg-david merged commit d7b4a3f into release/1.0.x Mar 17, 2026
63 checks passed
@frontegg-david frontegg-david deleted the fix-nx branch March 17, 2026 09:49
github-actions bot pushed a commit that referenced this pull request Mar 17, 2026
…ctions and commands

Cherry-picked from #284 (merged to release/1.0.x)
Original commit: d7b4a3f

Co-Authored-By: frontegg-david <69419539+frontegg-david@users.noreply.github.com>
@github-actions
Copy link
Contributor

Cherry-pick Created

A cherry-pick PR to main has been automatically created.

Please review and merge if this change should also be in main.

If the cherry-pick is not needed, close the PR.

frontegg-david added a commit that referenced this pull request Mar 17, 2026
…ctions and commands (#285)

Cherry-picked from #284 (merged to release/1.0.x)
Original commit: d7b4a3f

Co-authored-by: agentfront[bot] <agentfront[bot]@users.noreply.github.com>
Co-authored-by: frontegg-david <69419539+frontegg-david@users.noreply.github.com>
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.

1 participant