Skip to content

mrlonis/mrlonis-nx-monorepo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mrlonis - Nx - Monorepo

This project was generated using Nx.

🔎 Smart, Fast and Extensible Build System

Table of Contents

Quick Start & Documentation

Nx Documentation

10-minute video showing all Nx features

Interactive Tutorial

Adding capabilities to your workspace

Nx supports many plugins which add capabilities for developing different types of applications and different tools.

These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.

Below are our core plugins:

  • Angular
    • ng add @nx/angular
  • React
    • ng add @nx/react
  • Web (no framework frontends)
    • ng add @nx/web
  • Nest
    • ng add @nx/nest
  • Express
    • ng add @nx/express
  • Node
    • ng add @nx/node

There are also many community plugins you could add.

Generate an application

Run ng g @nx/angular:app my-app to generate an application.

You can use any of the plugins above to generate applications as well.

When using Nx, you can create multiple applications and libraries in the same workspace.

Generating a new Angular Application

Run the command nx g @nx/angular:application my-app-name

Reference

Generating a new Angular Application with Karma test runner

Run the command nx g @nx/angular:application my-app-name --unitTestRunner=karma

Adding @angular/material to an Angular application

Run the command: nx g @angular/material:ng-add --project=my-app-name

Reference

Generate a library

Run ng g @nx/angular:lib my-lib to generate a library.

You can also use any of the plugins above to generate libraries as well.

Libraries are shareable across libraries and applications. They can be imported from @mrlonis/mylib.

Generating a new TypeScript Library

Run the command nx g @nx/workspace:library my-lib-name

Reference

Generating a new buildable TypeScript Library

Run the command nx g @nx/workspace:library my-lib-name --buildable

Generating a new Angular Library

Run the command nx g @nx/angular:library my-lib-name

Reference

Generating a new Angular Library with Karma test runner

Run the command nx g @nx/angular:library my-lib-name --unitTestRunner=karma

Generating a new buildable Angular Library

Run the command nx g @nx/angular:library my-lib-name --buildable

Generating a new publishable Angular Library

Run the command nx g @nx/angular:library my-lib-name --publishable --importPath='some-path-to-import or like this @some/path-to-import'

Note: A Publishable library is also a buildable library, it is just built using partial compilation. Generating a "buildable / publishable" library likw nx g @nx/angular:library my-lib-name --buildable --publishable --importPath='some-path-to-import or like this @some/path-to-import' is ultimately redundant. It will not cause an error but there is no reason to pass the buildable flag.

Development server

Run ng serve my-app for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng g component my-component --project=my-app to generate a new component.

Generating a new Angular Component

Run the command nx g @nx/angular:component my-component-name --project=my-app-name

Example: nx g @nx/angular:component --name=my-component-name --path='apps/ngx-test-application/src/app/features' --project=my-app-name --module=my-module --style=scss

nx g @nx/angular:component --name=anime-grid --path='apps/ngx-test-application/src/app/features' --project=ngx-test-application --module=app --style=scss

Reference

Build

Run ng build my-app to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Running unit tests

Run ng test my-app to execute the unit tests via Jest.

Run nx affected:test to execute the unit tests affected by a change.

WSL - Required Packages for Testing

sudo apt-get update
sudo apt-get install libgbm-dev
sudo apt-get install -y curl unzip xvfb libxi6 libgconf-2-4
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
npm i -g cobertura-merge

Running end-to-end tests

Run ng e2e my-app to execute the end-to-end tests via Cypress.

Run nx affected:e2e to execute the end-to-end tests affected by a change.

Understand your workspace

Run nx graph to see a diagram of the dependencies of your projects.

Further help

Visit the Nx Documentation to learn more.

☁ Nx Cloud

Distributed Computation Caching & Distributed Task Execution

Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times. Even teams that are new to Nx can connect to Nx Cloud and start saving time instantly.

Teams using Nx gain the advantage of building full-stack applications with their preferred framework alongside Nx’s advanced code generation and project dependency graph, plus a unified experience for both frontend and backend developers.

Visit Nx Cloud to learn more.

Project Ports

  • 4203 - ngx-ui-personal-website
  • 4207 - ngx-table-virtual-scroll-sticky-headers
  • 4208 - ngx-virtual-scroll-cdk-table-example
  • 4209 - ngx-table-virtual-scroll-example
  • 4210 - ngx-test-application

Running the gauntlet

As part of the gauntlet, we run the Cypress e2e tests. This requires some backend APIs running. In 2 other shells, run the following commands:

Updating

npx nx migrate latest
npm install
npx nx migrate --run-migrations

Check https://github.com/nrwl/ci/releases for GitHub Actions workflow updates.

pre-commitGitHub Desktop Fix

The GitHub Desktop app uses a different env than the OS. To fix missing npx commands, we can edit the pre-commit file in the .husky directory:

#!/bin/bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"                   # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

nvm install 20
...