Skip to content

Conversation

@patrickkabwe
Copy link
Owner

@patrickkabwe patrickkabwe commented Jun 17, 2025

closes #221

Summary by CodeRabbit

  • New Features

    • Added support for the pnpm package manager throughout the CLI and package generation process.
    • pnpm is now available as an option in interactive prompts and is automatically detected in CI environments.
  • Improvements

    • Optimized configuration file generation with concurrent writes for improved efficiency.
    • Enhanced detection logic for package managers, ensuring better compatibility.
  • Chores

    • Updated CI workflows to include pnpm in testing and package generation steps.
    • Expanded documentation and examples to include pnpm usage in installation, module creation, and troubleshooting guides.
    • Removed one CLI command from the package to streamline executables.
    • Disabled commit message footer line length enforcement for improved commit flexibility.

@patrickkabwe patrickkabwe self-assigned this Jun 17, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Support for the pnpm package manager was added across the CLI, code generation logic, type definitions, utility functions, and CI workflow. This includes detection, selection, and handling of pnpm in interactive prompts, workspace configuration, package installation commands, and GitHub Actions workflows.

Changes

File(s) Change Summary
.github/workflows/test-nitro-cli.yml Added pnpm to CI matrix; added pnpm setup steps; adjusted commands and Node.js setup for pnpm compatibility.
src/cli/create.ts Added pnpm as a selectable/fallback package manager in prompts and CI mode.
src/generate-nitro-package.ts Added pnpm support for workspace config, install commands, and codegen scripts; optimized config file writes.
src/types.ts Changed PackageManager type to dynamically reflect detected package managers, including pnpm.
src/utils.ts Updated detectPackageManager to detect and return pnpm if present.
README.md, docs/docs/commands.md, docs/docs/usage/*.md Added pnpm usage examples and instructions in CLI docs and README.
docs/docs/troubleshooting.md Reformatted and updated troubleshooting docs to include pnpm in global CLI install instructions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant NitroModuleFactory
    participant Utils

    User->>CLI: Run CLI to create Nitro module
    CLI->>Utils: detectPackageManager()
    Utils-->>CLI: Returns 'pnpm' (if detected)
    CLI->>User: Prompt for package manager (includes pnpm)
    User-->>CLI: Selects 'pnpm'
    CLI->>NitroModuleFactory: Generate package with 'pnpm'
    NitroModuleFactory->>NitroModuleFactory: Configure pnpm workspace, commands, scripts
    NitroModuleFactory-->>CLI: Package generated with pnpm support
Loading

Assessment against linked issues

Objective Addressed Explanation
Add support for pnpm (#221)

Poem

In the warren of code, a new path was spun,
Now pnpm hops in, joining yarn, npm, and bun!
Workspaces are tidy, commands swift and keen,
Our CI now welcomes this package machine.
With every new feature, we leap and we run—
The future is bright, and the work is well done!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

commitlint.config.cjs

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@eslint/js' imported from /eslint.config.js
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c60a2f and a210a70.

📒 Files selected for processing (2)
  • commitlint.config.cjs (1 hunks)
  • package.json (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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

🔭 Outside diff range comments (2)
src/utils.ts (1)

206-214: Annotate return type for tighter PackageManager inference

detectPackageManager currently relies on TypeScript’s widening to string, which later causes PackageManager to degrade to string (see src/types.ts).
Provide an explicit literal-union return type so downstream code keeps strict exhaustiveness checks.

-export const detectPackageManager = () => {
+export const detectPackageManager = (): 'npm' | 'yarn' | 'bun' | 'pnpm' | undefined => {
.github/workflows/test-nitro-cli.yml (1)

293-319: pnpm missing from Android matrix

test-android-build defines pm: ['bun', 'yarn'] but still contains conditional steps for pnpm.
Either add 'pnpm' to the matrix or drop the dead steps to keep the workflow concise.

-                pm: ['bun', 'yarn']
+                pm: ['bun', 'yarn', 'pnpm']
🧹 Nitpick comments (4)
src/generate-nitro-package.ts (4)

145-148: Consider run for the pnpm postcodegen script

pnpm --filter ./example pod works only when pod is an npm-script or a binary on PATH.
If it’s an npm-script (same as npm/yarn cases) it’s safer to prepend run:

-        } else if (this.config.pm === 'pnpm') {
-            script = `pnpm --filter ./example pod`
+        } else if (this.config.pm === 'pnpm') {
+            script = `pnpm --filter ./example run pod`

192-203: Avoid delete + create workspace file in one shot

  1. delete newWorkspacePackageJsonFile.workspaces triggers the Biome warning.
    Cheaper: newWorkspacePackageJsonFile.workspaces = undefined.
  2. Building and writing pnpm-workspace.yaml looks good.
-            delete newWorkspacePackageJsonFile.workspaces
+            newWorkspacePackageJsonFile.workspaces = undefined

274-279: Use pnpm dlx instead of pnpx

pnpm ships an alias, but the documented way is pnpm dlx. Keeps parity with bunx / npx.

-                : this.config.pm === 'pnpm'
-                  ? 'pnpx'
+                : this.config.pm === 'pnpm'
+                  ? 'pnpm dlx'

408-465: Duplicate write & commented-out dead code

androidSettingsGradlePath is written once (408–412) and again inside filesToWrite.
Also, the large block of commented-out writeFile calls above clutters the method.

-        await writeFile(
-            androidSettingsGradlePath,
-            androidSettingsGradleCode(toPascalCase(this.config.packageName)),
-            { encoding: 'utf8' }
-        )
+        // initial write removed – now handled in the batched `filesToWrite`

Then delete the commented legacy lines (367-399, 377-386, 395-399) to keep the file clean.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54e47d1 and 841bed3.

📒 Files selected for processing (5)
  • .github/workflows/test-nitro-cli.yml (6 hunks)
  • src/cli/create.ts (2 hunks)
  • src/generate-nitro-package.ts (8 hunks)
  • src/types.ts (2 hunks)
  • src/utils.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/types.ts (1)
src/utils.ts (1)
  • detectPackageManager (206-214)
src/generate-nitro-package.ts (3)
src/utils.ts (2)
  • replacePlaceholder (168-192)
  • toPascalCase (59-64)
src/code-snippets/code.js.ts (3)
  • metroConfig (105-119)
  • babelConfig (121-140)
  • exampleTsConfig (142-151)
src/code-snippets/code.android.ts (1)
  • androidSettingsGradleCode (24-32)
🪛 Biome (1.9.4)
src/generate-nitro-package.ts

[error] 202-202: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Test iOS Build - pnpm - view (Debug)
  • GitHub Check: Test iOS Build - pnpm - module (Debug)
  • GitHub Check: Test iOS Build - pnpm - module (Release)
  • GitHub Check: Test iOS Build - yarn - view (Release)
  • GitHub Check: Test Android Build - yarn - view (Debug)
  • GitHub Check: Test Android Build - yarn - view (Release)
  • GitHub Check: Test iOS Build - yarn - module (Release)
  • GitHub Check: Test Android Build - bun - module (Debug)
  • GitHub Check: Test Android Build - yarn - module (Release)
  • GitHub Check: Test Android Build - bun - view (Debug)
  • GitHub Check: Test Android Build - bun - module (Release)
  • GitHub Check: Test Android Build - yarn - module (Debug)
  • GitHub Check: Test Android Build - bun - view (Release)
🔇 Additional comments (2)
src/cli/create.ts (2)

147-148: Default to pnpm in CI looks good

Switching the CI fallback from bunpnpm aligns with the new matrix – no concerns.


253-256: pnpm option added to the prompt – LGTM

Interactive users can now pick pnpm; implementation mirrors the other options.

Copy link

@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

🧹 Nitpick comments (2)
src/generate-nitro-package.ts (2)

202-207: Nitpick: double-space in constant & delete operator

  1. The double space before NPMRC_FILENAME will trip most linters.
  2. Static-analysis flagged delete – fine here, but an assignment to
    undefined is slightly faster and avoids the warning.
-            const  NPMRC_FILENAME = '.npmrc'
+            const NPMRC_FILENAME = '.npmrc'-            delete newWorkspacePackageJsonFile.workspaces
+            newWorkspacePackageJsonFile.workspaces = undefined

414-421: Duplicate writes – Android gradle file is written twice

androidSettingsGradlePath is written at line 414 and again inside
filesToWrite. Remove the first write or exclude it from the batch to
avoid redundant I/O.

Also applies to: 450-465

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 570bbcf and 9dc9fc0.

📒 Files selected for processing (1)
  • src/generate-nitro-package.ts (8 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/generate-nitro-package.ts (4)
assets/react-native.config.js (1)
  • path (1-1)
src/utils.ts (2)
  • replacePlaceholder (168-192)
  • toPascalCase (59-64)
src/code-snippets/code.js.ts (3)
  • metroConfig (105-119)
  • babelConfig (121-140)
  • exampleTsConfig (142-151)
src/code-snippets/code.android.ts (1)
  • androidSettingsGradleCode (24-32)
🪛 Biome (1.9.4)
src/generate-nitro-package.ts

[error] 208-208: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments (1)
src/generate-nitro-package.ts (1)

228-231: Install-command placeholder looks good

The switch now yields pnpm add, bun add, etc. Nice touch.

Comment on lines +279 to 285
const packageManager =
this.config.pm === 'bun'
? 'bunx'
: this.config.pm === 'pnpm'
? 'pnpx'
: 'npx -y'

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Use pnpm dlx, not pnpx, when the selected PM is pnpm

pnpx belongs to npm; on a pnpm-only environment it won’t exist.
pnpm dlx (or pnpm exec) is the correct analogue.

-                : this.config.pm === 'pnpm'
-                  ? 'pnpx'
+                : this.config.pm === 'pnpm'
+                  ? 'pnpm dlx'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const packageManager =
this.config.pm === 'bun'
? 'bunx'
: this.config.pm === 'pnpm'
? 'pnpx'
: 'npx -y'
const packageManager =
this.config.pm === 'bun'
? 'bunx'
: this.config.pm === 'pnpm'
? 'pnpm dlx'
: 'npx -y'
🤖 Prompt for AI Agents
In src/generate-nitro-package.ts around lines 279 to 285, replace the use of
'pnpx' with 'pnpm dlx' when the package manager is pnpm, because 'pnpx' is an
npm tool and may not be available in pnpm-only environments. Update the
conditional expression to use 'pnpm dlx' instead of 'pnpx' to correctly invoke
pnpm's execution command.

Copy link

@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: 0

🔭 Outside diff range comments (1)
src/generate-nitro-package.ts (1)

414-471: Duplicate writes — same files are written twice

androidSettingsGradlePath (and others) are individually written at 414-418 and then again via filesToWrite in the Promise.all block (450-463).
This is redundant I/O and invites inconsistent states if one write fails.

Option 1 (cleaner): remove the earlier individual writeFile calls and keep the batched Promise.all.

-        await writeFile(
-            androidSettingsGradlePath,
-            androidSettingsGradleCode(toPascalCase(this.config.packageName)),
-            { encoding: 'utf8' }
-        )

Option 2: keep the single writes and drop them from the list in filesToWrite.

Pick one path to avoid duplication.

♻️ Duplicate comments (2)
src/generate-nitro-package.ts (2)

279-285: Use pnpm dlx, not pnpx, for one-off CLI execution
This was already raised in the earlier review but is still unresolved.

pnpx is shipped with npm, not pnpm; it will be missing in a pnpm-only setup.
Replace with pnpm dlx (or pnpm exec) to ensure compatibility.

-                : this.config.pm === 'pnpm'
-                  ? 'pnpx'
+                : this.config.pm === 'pnpm'
+                  ? 'pnpm dlx'

145-147: pnpm command is still missing the required run keyword

pnpm executes workspace-local scripts via pnpm run ….
Without run, pnpm will attempt to treat pod as a package to install, resulting in failure.

-        } else if (this.config.pm === 'pnpm') {
-            script = `pnpm --filter ./example pod`
+        } else if (this.config.pm === 'pnpm') {
+            script = `pnpm --filter ./example run pod`
🧹 Nitpick comments (1)
src/generate-nitro-package.ts (1)

192-209: Prefer property assignment over delete to avoid V8 de-opt

Static-analysis flagged delete newWorkspacePackageJsonFile.workspaces.
Assigning undefined keeps the object shape stable and is marginally faster.

-            delete newWorkspacePackageJsonFile.workspaces
+            newWorkspacePackageJsonFile.workspaces = undefined
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9dc9fc0 and 6c60a2f.

📒 Files selected for processing (1)
  • src/generate-nitro-package.ts (8 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/generate-nitro-package.ts

[error] 208-208: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

BREAKING CHANGE: The CLI entry point 'nitro-module' is no longer available in the package's bin field.
@patrickkabwe patrickkabwe merged commit 5134d24 into main Jun 17, 2025
2 of 3 checks passed
@patrickkabwe patrickkabwe deleted the feat/pnpm-support branch June 17, 2025 08:26
@github-actions
Copy link
Contributor

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add support for pnpm

2 participants