NxRocks

repository·develop·Indexed 43 days ago

https://github.com/tinesoft/nxrocks

A suite of Nx plugins and scaffolding CLIs to integrate frameworks such as Spring Boot, Flutter, Quarkus, Micronaut, and Ktor into Nx monorepos. It provides specialized tools like create-nx-flutter, create-nx-ktor, create-nx-micronaut, create-nx-quarkus, and create-nx-spring-boot for workspace generation, along with plugins like @nxrocks/nx-flutter for project generation and executor-based management of Flutter projects.

Tokens
38.9K
Snippets
145
Records
192
Agent score
55%

What's inside NxRocks

  1. Overview of NxRocks plugins and CLIs

    develop

    NxRocks is a collection of Nx plugins and custom CLIs designed to enhance Nx workspaces by providing first-class support for various frameworks and tools.

    Available Nx Plugins

    These plugins allow you to generate, run, package, and build specific framework projects within an existing Nx workspace:

    • nx-spring-boot: Support for Spring Boot projects.
    • nx-flutter: Support for Flutter projects.
    • nx-quarkus: Support for Quarkus projects.
    • nx-micronaut: Support for Micronaut projects.
    • nx-melos: Support for Melos.
    • nx-ktor: Support for Ktor projects.

    Available Custom CLIs

    These CLIs are used to bootstrap new Nx workspaces that come with built-in support for specific frameworks:

    • create-nx-spring-boot: Creates Nx workspaces with Spring Boot support.
    • create-nx-flutter: Creates Nx workspaces with Flutter support.
    • create-nx-quarkus: Creates Nx workspaces with Quarkus support.
    • create-nx-micronaut: Creates Nx workspaces with Micronaut support.
    • create-nx-ktor: Creates Nx workspaces with Ktor support.
  2. Features of the nx-spring-boot plugin

    develop

    The @nxrocks/nx-spring-boot plugin provides the following capabilities for managing Spring Boot projects within an Nx workspace:

    • Spring Initializr Integration: Generates Spring Boot applications and libraries based on the Spring Initializr API.
    • Lifecycle Management: Supports building, packaging, testing, and more for Spring Boot projects.
    • Multi-module Support: Built-in support for creating multi-module Spring Boot projects using either Maven or Gradle.
    • Code Formatting: Integrated support for the Spotless plugin for both Maven and Gradle.
    • Proxy Support: Supports corporate proxies via the --proxyUrl flag or standard environment variables (http_proxy, HTTP_PROXY, https_proxy, or HTTPS_PROXY).
    • Nx Dependency Graph Integration: Integrates with Nx's dependency graph (e.g., nx graph or nx affected:graph), allowing you to visualize dependencies of Maven/Gradle Spring Boot applications and libraries just like native JS/TS projects.
  3. Use Nx executors for Flutter projects

    develop

    Once a Flutter app is generated within an Nx workspace, you can manage it using executors. These executors are kebab-cased wrappers around standard flutter and dart commands.

    To run an executor, you can use the nx <executor> <project> syntax or the more explicit nx run <project>:<executor> syntax.

    Passing Arguments Executors accept the same additional arguments as the original underlying commands. You can pass them using the --option=value syntax. If an argument contains spaces (like an executable command), wrap it in quotes.

    # Using the short syntax
    $ nx gen-l10n your-flutterapp --header="/// my header"
    $ nx pub-add your-flutterapp --package=build_runner
    $ nx pub-run your-flutterapp --executable="build_runner build"
    
    # Using the explicit 'run' syntax
    $ nx run your-flutterapp:gen-l10n --header="/// my header"
    $ nx run your-flutterapp:pub-add --package=build_runner
    $ nx run your-flutterapp:pub-run --executable="build_runner build"
  4. Use Nx executors for Micronaut projects

    develop

    The @nxrocks/nx-micronaut plugin provides several executors to manage Micronaut applications and libraries within an Nx workspace. By default, these executors use the embedded ./mvnw or ./gradlew wrappers generated with your project.

    To use a globally installed mvn or gradle instead of the wrapper (useful in CI or restricted environments), use the --ignoreWrapper option.

    You can pass additional arguments to the underlying Maven or Gradle commands temporarily using the --args flag, or permanently by configuring the args array in your workspace.json (or project.json) file.

    # Temporary arguments via CLI
    nx run your-micronaut-app --args="-Dpackaging=docker-native"
    // Permanent configuration in workspace.json
    {
      "targets": {
        "dockerfile": {
          "executor": "@nxrocks/nx-micronaut:dockerfile",
          "options": {
            "root": "apps/your-micronaut-app",
            "args": ["-Dpackaging=docker-native"]
          }
        }
      }
    }
  5. How @nxrocks/nx-flutter integrates with Nx

    develop

    The @nxrocks/nx-flutter plugin provides first-class support for Flutter within an Nx workspace by:

    1. Leveraging Flutter CLI: It uses the official Flutter CLI API for generation, building, packaging, and testing.
    2. Dependency Graph Integration: Flutter projects are integrated into the Nx dependency graph. This allows you to use nx dep-graph or nx affected:dep-graph to visualize dependencies between Flutter projects and other workspace projects, just like native JS/TS projects.
  6. Understand the purpose of Smoke tests

    develop

    The smoke tests in this project are designed to validate the end-to-end (e2e) experience of creating and using Nx workspaces. Unlike e2e-core tests, these tests use bunx create-nx-workspace ... to generate the workspace and do not rely on e2e utilities from nx-plugin.

    This approach is used specifically to detect regressions or breakages caused by updates to Nx itself or to the plugins being tested, ensuring that the user-facing creation flow remains functional.

  7. Quickstart with create-nx-quarkus CLI

    develop

    The fastest way to get started is using the create-nx-quarkus CLI. This tool creates a new Nx workspace with the @nxrocks/nx-quarkus plugin already pre-installed.

    Run one of the following commands:

    # Using npm
    npx create-nx-quarkus@latest
    
    # Using yarn
    yarn create nx-quarkus
    npx create-nx-quarkus@latest
  8. Quickstart with create-nx-ktor CLI

    develop

    The fastest way to get started is using the create-nx-ktor CLI, which creates a new Nx workspace with the @nxrocks/nx-ktor plugin pre-installed.

    Run one of the following commands:

    # npm
    npx create-nx-ktor@latest
    
    # yarn
    yarn create nx-ktor
    # npm
    npx create-nx-ktor@latest
    
    # yarn
    yarn create nx-ktor
  9. Quickstart with create-nx-micronaut CLI

    develop

    The fastest way to get started is using the create-nx-micronaut CLI. This tool creates a new Nx workspace with the @nxrocks/nx-micronaut plugin already pre-installed.

    Run one of the following commands:

    # npm
    npx create-nx-micronaut@latest
    
    # or
    
    yarn
    yarn create nx-micronaut
    npx create-nx-micronaut@latest
  10. Quickstart with create-nx-flutter CLI

    develop

    The easiest way to get started is using the create-nx-flutter CLI. This tool creates a new Nx workspace with the @nxrocks/nx-flutter plugin already pre-installed and configured.

    Run one of the following commands to begin the setup process:

    # npm
    npx create-nx-flutter@latest
    
    # or
    # yarn
    yarn create nx-flutter
  11. Install and use create-nx-spring-boot

    develop

    Use create-nx-spring-boot to scaffold a new Nx workspace that includes built-in support for Spring Boot projects via the @nxrocks/nx-spring-boot plugin. The CLI provides an interactive step-by-step guide to setting up your workspace.

    Prerequisites

    • NodeJS: Installed and available in your PATH (preferably the current LTS version).
    • JRE or JDK: Installed and available in your PATH (required for creating and running Spring Boot projects).
    npx create-nx-spring-boot your-workspace-name
  12. Manual Setup for @nxrocks/nx-flutter

    develop

    If you already have an Nx workspace, follow these steps to add Flutter support:

    1. Prerequisites

    Ensure you have the Flutter CLI installed on your system.

    2. Create an Nx workspace

    If you don't have one, create it using:

    # npm
    npx create-nx-workspace@latest
    
    # yarn
    yarn create nx-workspace@latest

    3. Install the Plugin

    Install the @nxrocks/nx-flutter plugin as a development dependency:

    # npm
    npm install @nxrocks/nx-flutter --save-dev
    
    # yarn
    yarn add @nxrocks/nx-flutter --dev
    npm install @nxrocks/nx-flutter --save-dev