Rizing Monorepo
đ Quick Startâ
If your environment is already setup:
git clone https://rizing-devops@dev.azure.com/rizing-devops/rizing/_git/monorepo
cd monorepo
npm install
See Cloning a Repository docs for help on cloning a repository for the first time in ADO.
âšī¸ Overviewâ
The Rizing Geospatial products team uses a mono-repository style structure (aka monorepo). There are many reasons and specific advantages behind the choice to use this architecture (which can be read here). The monorepo is used to house all Geospatial products within Rizing. Additionally, this repository consists of hundreds of re-usable components and dozens of distributable packages that can be used by other developers at Rizing.
đŋ Environment Setupâ
Dependenciesâ
The following dependencies are necessary to be installed on your machine:
- Git
- NodeJS
- Visual Studio Code (not required, but recommended)
NodeJS (NVM) Setupâ
It's highly recommended to use Node Version Manager (nvm), rather than directly installing a version of NodeJS. This will allow you to effortlessly install and switch between NodeJS versions.
Download and install one of the following:
- NVM for Mac or Linux
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
- NVM for Windows
- Download and run latest installer
Install NodeJS >= 20.10.0
# Install NodeJS version
nvm install 20
# Set as active version
nvm use 20
Clone Repositoryâ
git clone https://rizing-devops@dev.azure.com/rizing-devops/rizing/_git/monorepo
Generate a Personal Access Token in Azure DevOps if necessary.
Open Codeâ
- Open the root folder in Visual Studio Code (or other IDE if preferred)
- When prompted from Visual Studio Code to install the recommended extensions, click "Yes"
- Install NodeJS packages (
npm install
)
Structureâ
The repository has the following structure:
đĻ monorepo # repo root
âŖ đ apps # contains all NodeJS apps
â âŖ đ app1
â âŖ đ app2
â â đ app3
âŖ đ docs # contains all application documentation (using Docusaurus)
â âŖ đ app1
â âŖ đ app2
â âŖ đ app3
â â đ dev-guide # developer guide docs
â đ libs # re-usable library code, broken down into packages (libs)
âŖ đ lib1
âŖ đ lib2
â đ storybook-host # storybook server that pulls all stories from all libs
đ Common Commandsâ
The following are reference commands. For more details on CLI arguments, see the NX API documentation.
Run applicationâ
Start an application
npm run start -- {YOUR_APP}
Start multiple applications at the same time
npm run nx -- run-many --target=serve --projects={APP_1},{APP_2} --parallel
Create projectâ
Create standard TS library
npm run nx -- generate @nx/js:library YOUR_LIB --unitTestRunner=jest --publishable --importPath=@rizing/YOUR_LIB --tags=pure --no-interactive
Create node library
npm run nx -- g @nrwl/node:lib some-lib --publishable --importPath=@rizing/some-lib
Create Angular library
npm run nx -- generate @nx/angular:library YOUR_LIB-angular --publishable --changeDetection=OnPush --importPath=@rizing/YOUR_LIB --prefix=rz --skipModule --standalone --style=scss --tags='angular' --no-interactive
Create Nest.js App
npm run nx -- g @nx/nest:app YOUR_APP --strict
Modify projectâ
Remove project
npm run nx -- g remove {some-project} --forceRemove
Move project
npm run nx -- g move --project booking-some-library shared/some-library
Create Angular componentsâ
Create Angular component
npm run nx -- generate @nx/angular:component --standalone --changeDetection=OnPush --prefix=rz --no-interactive --project=YOUR_LIB YOUR_COMPONENT
Lintingâ
Lint affected (changes)
npm run lint:affected
Lint a project
npm run lint -- YOUR_TARGET_PROJECT
Lint all projects
npm run nx -- run-many -t lint
Testingâ
Test affected (changes)
npm run test:affected
Test project (single run)
npm run test -- {YOUR_PROJECT}
Test project w/ hotreload (keep watching for changes)
npm run test -- {YOUR_PROJECT} --watch
Test project w/ debugging
npm run test -- {YOUR_PROJECT} --inspect
Build projectâ
Build single project
# Swap "production" for desired configuration
npm run nx -- run YOUR_PROJECT:build:production
Storybookâ
Configure Storybook for a project
npm run nx -- g @nx/angular:storybook-configuration PROJECT_NAME
Start global story book
npx run storybook
Start storybook for a specific library
npm run nx -- storybook YOUR_LIBRARY
Build production storybook site
npm run nx -- run STORYBOOK_PROJECT:build-storybook
NX Workspaceâ
Show NX graph
npm run nx -- graph
Clear NX cache
npm run nx -- clear-cache
Updatesâ
Get latest updates
npm run nx -- migrate latest
Apply latest updates (apply migrations)
npm run nx -- migrate --run-migrations
Check for outdated NPM packages
npm outdated
TypeOrmâ
Create TypeOrm migration
npm run typeorm -- -d ./apps/omni-api/typeorm.config.ts migration:generate ./apps/omni-api/src/migrations/YOUR_MIGRATION_NAME
Gitâ
Delete all local git branches
# Mac:
git for-each-ref --format '%(refname:short)' refs/heads | grep -v master | xargs git branch -D
# Windows
git branch | grep -v "main" | xargs git branch -D
đ Notesâ
Unit tests using the ArcGIS JS APIâ
When a library has unit tests that uses the ArcGIS JS API, it is necessary to adjust the library's Jest config to properly handle the dependency.
// Add any additional node module packages to the regex pattern.
"transformIgnorePatterns": [
"node_modules/(?!(@angular|@arcgis|@esri|@stencil/)"
],