8000 chore: add turbo to nextjs dev server by mattinannt · Pull Request #3529 · formbricks/formbricks · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: add turbo to nextjs dev server #3529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2024
Merged

Conversation

mattinannt
Copy link
Member
@mattinannt mattinannt commented Oct 12, 2024

This pull request includes several updates across multiple packages to improve the development workflow and enhance file path security. The most important changes include adding the --turbo flag to various next dev commands, ensuring safe file path resolution in the getLocalFile function, and renaming a script command in the react-native package.

Development Workflow Improvements:

File Path Security Enhancement:

Summary by CodeRabbit

  • New Features

    • Enhanced development server startup with turbo mode for improved performance in both demo and web projects.
    • Updated version for the React Native package to 1.1.0.
  • Bug Fixes

    • Improved file path handling in local file operations for increased reliability.
  • Chores

    • Renamed the go script to dev in the React Native package for clarity.

Copy link
vercel bot commented Oct 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
formbricks-cloud 🔄 Building (Inspect) Visit Preview 💬 Add feedback Oct 12, 2024 8:30am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
formbricks-docs ⬜️ Ignored (Inspect) Oct 12, 2024 8:30am

Copy link
Contributor
coderabbitai bot commented Oct 12, 2024

Walkthrough

The pull request introduces modifications to several package.json files across different projects, specifically updating the script commands to include the --turbo flag for enhanced functionality during development. The getLocalFile function in the storage service has also been adjusted to ensure it resolves file paths to absolute paths, improving file operation reliability.

Changes

File Path Change Summary
apps/demo/package.json Updated script go from "next dev -p 3002" to "next dev -p 3002 --turbo"
apps/web/package.json Updated scripts dev and go from "next dev -p 3000" to "next dev -p 3000 --turbo"
packages/lib/storage/service.ts Modified getLocalFile to resolve file paths to absolute paths using path.resolve
packages/react-native/package.json Renamed script go to dev with command unchanged: "vite build --watch --mode dev"

Possibly related PRs

  • fix: Make js assets cachable #3337: The changes in this PR also involve modifications to the package.json file, specifically updating the go script to include the --turbo flag, similar to the changes made in the main PR for the @formbricks/demo project.
  • chore: add react email dev server & fix package npm deps #3350: This PR includes updates to the apps/web/package.json, where the go script is modified to include the --turbo flag, directly relating to the changes made in the main PR.

Suggested reviewers

  • pandeymangg

🐰 In the garden, I hop and play,
With scripts that turbo all the way!
From demo to web, we make it right,
Coding through day, and into the night!
Paths resolved, our files in sight,
Hooray for changes, what a delight! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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
Contributor
github-actions bot commented Oct 12, 2024

Thank you for following the naming conventions for pull request titles! 🙏

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

🧹 Outside diff range and nitpick comments (3)
apps/demo/package.json (1)

8-8: LGTM! Consider renaming the script for clarity.

The addition of the --turbo flag to the go script aligns with the PR objectives and should improve development performance. This change also makes it consistent with the dev script.

Consider renaming the go script to something more descriptive like dev:turbo or dev:alt for better clarity and consistency with common naming conventions. This would make the purpose of the script more immediately apparent to other developers.

apps/web/package.json (1)

7-8: Consider consolidating identical scripts

The dev and go scripts are now identical. To improve maintainability and reduce potential confusion, consider one of the following options:

  1. Consolidate the scripts by removing one and updating any references to it.
  2. If there's a specific reason for having both, add comments explaining their distinct purposes.

Example consolidation:

 "scripts": {
   "dev": "next dev -p 3000 --turbo",
-  "go": "next dev -p 3000 --turbo",
+  "go": "npm run dev",
   ...
 }

This change maintains both command options while reducing duplication.

packages/lib/storage/service.ts (1)

Line range hint 1-385: Consider applying consistent security measures and improving error handling

While the security enhancement in getLocalFile is excellent, consider applying similar measures to other functions dealing with local file paths for consistency. For example, putFileToLocalStorage and deleteLocalFile could benefit from similar path resolution.

Additionally, the error handling across the file, including in getLocalFile, is minimal. Consider implementing more specific error types and handling to provide clearer feedback on what went wrong. This could involve creating custom error classes for different scenarios (e.g., FileNotFoundError, PermissionDeniedError) and catching them specifically in the calling code.

Would you like assistance in implementing these suggestions across the file?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 36cb4f6 and c3b3224.

📒 Files selected for processing (4)
  • apps/demo/package.json (1 hunks)
  • apps/web/package.json (1 hunks)
  • packages/lib/storage/service.ts (1 hunks)
  • packages/react-native/package.json (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
packages/react-native/package.json (1)

38-38: Approve script renaming for improved clarity.

The renaming of the "go" script to "dev" enhances clarity and aligns with common development conventions. This change improves the readability and maintainability of the package.json file.

To ensure this change doesn't break existing workflows, please run the following script to check for any references to the old script name:

If this script returns any results, those locations may need to be updated to use "dev" instead of "go".

apps/web/package.json (1)

7-8: Turbo mode enabled for development server

The --turbo flag has been added to both the dev and go scripts. This change aims to leverage Next.js's Turbopack, which can significantly improve development performance.

Considerations:

  1. Ensure all team members are aware of this change, as it might affect their local development workflow.
  2. Verify compatibility with your current Next.js version, as Turbopack is still in beta.
  3. Monitor for any unexpected behavior or compatibility issues with your project's specific setup.
  4. Consider adding a non-turbo script (e.g., dev:classic) for fallback if issues arise.

To ensure compatibility and proper setup, please run the following verification script:

✅ Verification successful

Turbo mode properly configured for development scripts

The --turbo flag has been successfully added to both the dev and go scripts, and the current Next.js version (14.2.15) supports Turbopack. This configuration should enhance development performance as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Next.js version and Turbopack compatibility

# Check Next.js version
next_version=$(npm list next --json | jq -r '.dependencies.next.version')
echo "Current Next.js version: $next_version"

# Check if Turbopack is mentioned in the Next.js docs
turbopack_docs=$(curl -s "https://nextjs.org/docs/app/api-reference/next-cli#turbo" | grep -c "turbo")

if [ $turbopack_docs -gt 0 ]; then
    echo "Turbopack is mentioned in the Next.js docs for the current version."
else
    echo "Warning: Turbopack might not be fully supported in the current Next.js version."
fi

# Test running the dev server with --turbo
echo "Testing dev server with --turbo flag..."
timeout 10s npm run dev || echo "Dev server with --turbo flag started successfully."

Length of output: 800


Script:

#!/bin/bash
# Description: Extract Next.js version from package.json without using npm

# Check if package.json exists
if [ ! -f apps/web/package.json ]; then
  echo "Error: apps/web/package.json not found."
  exit 1
fi

# Extract Next.js version using jq
next_version=$(jq -r '.dependencies.next' apps/web/package.json)

if [ "$next_version" != "null" ] && [ -n "$next_version" ]; then
  echo "Current Next.js version: $next_version"
else
  echo "Next.js is not listed as a dependency in apps/web/package.json."
fi

# Check if Turbopack is referenced in scripts
turbopack_usage=$(jq -r '.scripts | to_entries[] | select(.value | contains("--turbo")) | .key' apps/web/package.json)

if [ -n "$turbopack_usage" ]; then
  echo "Turbopack is used in the following scripts: $turbopack_usage"
else
  echo "Turbopack is not referenced in the scripts section of apps/web/package.json."
fi

Length of output: 498

packages/lib/storage/service.ts (1)

129-130: Excellent security enhancement!

The use of path.resolve(process.cwd(), filePath) is a great improvement. It ensures that the file path is resolved to an absolute path, which helps prevent potential directory traversal attacks. This change enhances the security of the getLocalFile function without altering its core functionality.

@mattinannt mattinannt merged commit 6ec748f into main Oct 12, 2024
16 of 17 checks passed
@mattinannt mattinannt deleted the feature/enable-turbo branch October 12, 2024 08:42
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
0